isglobal-brge / methylclock

DNA methylation-based clocks
MIT License
39 stars 21 forks source link

Bug with DNAmAge when using the age argument #34

Open Pierre9344 opened 6 months ago

Pierre9344 commented 6 months ago

Hello,

When I add a vector of numeric value to the age argument, the DNAmAge function fail with the error message next:

Error in methylclock::DNAmAge(myBvals, age = AgeAtV1) : 
  cell counts cannot be estimated since
                meffilEstimateCellCountsFromBetas function is giving an error.
                Probably your data do not have any of the required CpGs for that for that
                reference panel.

What is weird is that if I remove the age argument, the function work even when I don't specify a specific clock.

Any idea of what can cause that? I'm using the latest version (on bioconductor) with R 4.3.3.

Pierre9344 commented 6 months ago

I get the same problem with the example data:

> library(methylclock)
Loading required package: methylclockData
Loading required package: devtools
Loading required package: usethis
Loading required package: quadprog
Registered S3 methods overwritten by 'ggpp':
  method                  from   
  heightDetails.titleGrob ggplot2
  widthDetails.titleGrob  ggplot2
Registered S3 method overwritten by 'ggpmisc':
  method                  from   
  as.character.polynomial polynom
Setting options('download.file.method.GEOquery'='auto')
Setting options('GEOquery.inmemory.gpl'=FALSE)
Warning message:
replacing previous import ‘utils::findMatches’ by ‘S4Vectors::findMatches’ when loading ‘ExperimentHubData’ 
> library(tidyverse)
── Attaching core tidyverse packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package to force all conflicts to become errors
> path <- system.file("extdata", package = "methylclock")
> covariates <- read_csv(file.path(path, "SampleAnnotationExample55.csv"))
Rows: 16 Columns: 14                                                                                                                                                                                            
── Column specification ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Delimiter: ","
chr (6): id, title, geo_accession, TissueDetailed, Tissue, CauseofDeath
dbl (6): OriginalOrder, diseaseStatus, Age, PostMortemInterval, individual, Female
lgl (2): Caucasian, FemaleOriginal

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
> covariates
# A tibble: 16 × 14
   OriginalOrder id        title           geo_accession TissueDetailed Tissue diseaseStatus   Age PostMortemInterval CauseofDeath individual Female Caucasian FemaleOriginal
           <dbl> <chr>     <chr>           <chr>         <chr>          <chr>          <dbl> <dbl>              <dbl> <chr>             <dbl>  <dbl> <lgl>     <lgl>         
 1             3 GSM946048 Autism_occ_AN0… GSM946048     Fresh frozen … occip…             1    60               26.5 cancer               18      0 NA        NA            
 2             4 GSM946049 Control_occ_AN… GSM946049     Fresh frozen … occip…             0    39               NA   cardiac               2      0 NA        NA            
 3             7 GSM946052 Autism_occ_AN0… GSM946052     Fresh frozen … occip…             1    28               43   cancer                3      0 NA        NA            
 4             9 GSM946054 Autism_occ_AN0… GSM946054     Fresh frozen … occip…             1    39               14   cardiac               6      0 NA        NA            
 5            10 GSM946055 Autism_occ_AN1… GSM946055     Fresh frozen … occip…             1     8               22.2 cancer                4      0 NA        NA            
 6            11 GSM946056 Autism_occ_AN0… GSM946056     Fresh frozen … occip…             1    22               25   hypoxia               8      0 NA        NA            
 7            14 GSM946059 Control_occ_UM… GSM946059     Fresh frozen … occip…             0     4               17   cardiac              28      0 NA        NA            
 8            17 GSM946062 Control_occ_UM… GSM946062     Fresh frozen … occip…             0    28               13   other                35      0 NA        NA            
 9            19 GSM946064 Autism_occ_AN0… GSM946064     Fresh frozen … occip…             1     5               25.5 hypoxia              21      0 NA        NA            
10            20 GSM946065 Autism_occ_AN0… GSM946065     Fresh frozen … occip…             1     2                4   hypoxia              14      0 NA        NA            
11            21 GSM946066 Autism_occ_AN1… GSM946066     Fresh frozen … occip…             1    30               16   cardiac              17      0 NA        NA            
12            22 GSM946067 Control_occ_BT… GSM946067     Fresh frozen … occip…             0     1               19   unknown              30      0 NA        NA            
13            28 GSM946073 Control_occ_AN… GSM946073     Fresh frozen … occip…             0    60               24.2 unknown              13      0 NA        NA            
14            29 GSM946074 Control_occ_AN… GSM946074     Fresh frozen … occip…             0    22               21.5 unknown              24      0 NA        NA            
15            30 GSM946075 Control_occ_UM… GSM946075     Fresh frozen … occip…             0     8                5   cardiac              33      0 NA        NA            
16            31 GSM946076 Control_occ_AN… GSM946076     Fresh frozen … occip…             0    30               15   hypoxia              11      0 NA        NA            
> age <- covariates$Age
> head(age)
[1] 60 39 28 39  8 22
> age.example55 <- DNAmAge(MethylationData, age=age, cell.count=TRUE)
Error: object 'MethylationData' not found
> library(tidyverse)
> MethylationData <- get_MethylationDataExample()
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
downloading 1 resources
retrieving 1 resource
  |===================================================================================================================================================================| 100%

loading from cache
> MethylationData
# A tibble: 27,578 × 17
   ProbeID    GSM946048 GSM946049 GSM946052 GSM946054 GSM946055 GSM946056 GSM946059 GSM946062 GSM946064 GSM946065 GSM946066 GSM946067 GSM946073 GSM946074 GSM946075 GSM946076
   <chr>          <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
 1 cg00000292    0.706    0.730     0.705     0.751     0.715     0.634     0.682     0.635     0.728     0.777     0.601     0.752     0.671     0.768     0.749     0.665  
 2 cg00002426    0.272    0.274     0.311     0.279     0.178     0.269     0.330     0.501     0.197     0.282     0.203     0.221     0.238     0.188     0.232     0.179  
 3 cg00003994    0.0370   0.0147    0.0171    0.0290    0.0163    0.0243    0.0127    0.0206    0.0151    0.0105    0.0290    0.0145    0.0330    0.0251    0.0219    0.0213 
 4 cg00005847    0.133    0.120     0.121     0.107     0.110     0.129     0.102     0.124     0.104     0.108     0.122     0.125     0.132     0.0910    0.0990    0.0955 
 5 cg00006414    0.0309   0.0192    0.0217    0.0132    0.0181    0.0243    0.0199    0.0143    0.0184    0.0173    0.0179    0.0183    0.0181    0.0136    0.0185    0.0177 
 6 cg00007981    0.0700   0.0715    0.0655    0.0719    0.0914    0.0508    0.0294    0.0564    0.0458    0.0377    0.0413    0.0579    0.0354    0.0415    0.0342    0.0469 
 7 cg00008493    0.993    0.993     0.993     0.994     0.991     0.994     0.993     0.996     0.992     0.994     0.994     0.993     0.995     0.993     0.991     0.991  
 8 cg00008713    0.0215   0.0202    0.0187    0.0169    0.0162    0.0143    0.0172    0.0189    0.0194    0.0188    0.0153    0.0199    0.0171    0.0180    0.0178    0.0167 
 9 cg00009407    0.0105   0.00518   0.00410   0.00671   0.00758   0.00518   0.00543   0.00624   0.00642   0.00680   0.00712   0.00769   0.00662   0.00475   0.00632   0.00712
10 cg00010193    0.634    0.635     0.621     0.639     0.599     0.591     0.594     0.583     0.610     0.631     0.618     0.617     0.617     0.593     0.581     0.623  
# ℹ 27,568 more rows
# ℹ Use `print(n = ...)` to see more rows
> age.example55 <- DNAmAge(MethylationData, age=age, cell.count=TRUE)
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
 rows : 353 cols : 16
snapshotDate(): 2023-10-24
see ?methylclockData and browseVignettes('methylclockData') for documentation
loading from cache
Error in DNAmAge(MethylationData, age = age, cell.count = TRUE) : 
  cell counts cannot be estimated since
                meffilEstimateCellCountsFromBetas function is giving an error.
                Probably your data do not have any of the required CpGs for that
                reference panel.
In addition: Warning messages:
1: In predAge(cpgs.imp, coefHannum, intercept = FALSE, min.perc) :
  The number of missing CpGs forHannumclock exceeds 80%.
  ---> This DNAm clock will be NA.

2: In predAge(cpgs.imp, coefSkin, intercept = TRUE, min.perc) :
  The number of missing CpGs forSkinclock exceeds 80%.
  ---> This DNAm clock will be NA.

3: In predAge(cpgs.imp, coefPedBE, intercept = TRUE, min.perc) :
  The number of missing CpGs forPedBEclock exceeds 80%.
  ---> This DNAm clock will be NA.

4: In predAge(cpgs.imp, coefTL, intercept = TRUE, min.perc) :
  The number of missing CpGs forTLclock exceeds 80%.
  ---> This DNAm clock will be NA.

5: In predAge(cpgs.imp, coefBLUP, intercept = TRUE, min.perc) :
  The number of missing CpGs forBLUPclock exceeds 80%.
  ---> This DNAm clock will be NA.

6: In predAge(cpgs.imp, coefEN, intercept = TRUE, min.perc) :
  The number of missing CpGs forENclock exceeds 80%.
  ---> This DNAm clock will be NA.