caravagnalab / CNAqc

CNAqc - Copy Number Alteration (CNA) Quality Check package
GNU General Public License v3.0
17 stars 8 forks source link

Non-numeric argument to mathematical function dbinom #4

Closed ahorn720 closed 3 years ago

ahorn720 commented 3 years ago

Im very excited to use this software, thank you so much for preparing it.

I've run into an issue with a finicky sample can I can't figure out what's wrong.

ccfs = list()
for (sample in samples) {
  x = init(snvs = snvs%>%filter(Samples==sample),
           cna = cnvs%>%filter(Samples==sample),
           purity = purity%>%filter(Samples==sample)%>%select(Purity),
           ref = "hg38")
  ccf = compute_CCF(x)
  ccf.data = CCF(ccf)
  ccf.data$CCF[ccf.data$CCF>=1] = 1
  ccfs[[sample]] = ccf.data
}

However I get an error for only one of my samples at this function...

>   ccf = compute_CCF(x)
── Computing mutation multiplicity for karyotype 2:0 using raw VAF cuts. ──────────────────────────────────────────────
ℹ Expected Binomial peak(s) for these calls (1 and 2 copies): .
Error in qbinom(quantile_left, n, p) : 
  Non-numeric argument to mathematical function

its worth noting that all the samples before this one had a Karyotype of 1:1 but this sample had 2:0.

Any suggestions?

Thank you!

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] wesanderson_0.3.6  ggsci_2.9          CNAqc_0.1.0        RColorBrewer_1.1-2 peakPick_0.11      ggpubr_0.4.0      
 [7] crayon_1.3.4       pio_0.1.0          forcats_0.5.0      stringr_1.4.0      dplyr_1.0.2        purrr_0.3.4       
[13] readr_1.3.1        tidyr_1.1.2        tibble_3.0.4       ggplot2_3.3.2      tidyverse_1.3.0   

loaded via a namespace (and not attached):
 [1] fs_1.5.0            usethis_1.6.3       lubridate_1.7.9     devtools_2.3.2      httr_1.4.2         
 [6] rprojroot_1.3-2     tools_4.0.2         backports_1.1.10    utf8_1.1.4          R6_2.4.1           
[11] DBI_1.1.0           colorspace_1.4-1    withr_2.3.0         tidyselect_1.1.0    prettyunits_1.1.1  
[16] processx_3.4.4      curl_4.3            compiler_4.0.2      cli_2.1.0           rvest_0.3.6        
[21] xml2_1.3.2          desc_1.2.0          labeling_0.3        scales_1.1.1        callr_3.4.4        
[26] digest_0.6.27       foreign_0.8-80      rmarkdown_2.3       rio_0.5.16          pkgconfig_2.0.3    
[31] htmltools_0.5.0     sessioninfo_1.1.1   dbplyr_1.4.4        rlang_0.4.8         readxl_1.3.1       
[36] rstudioapi_0.11     farver_2.0.3        generics_0.0.2      jsonlite_1.7.1      zip_2.1.1          
[41] car_3.0-9           magrittr_1.5        Rcpp_1.0.5          munsell_0.5.0       fansi_0.4.1        
[46] abind_1.4-5         lifecycle_0.2.0     stringi_1.5.3       yaml_2.2.1          carData_3.0-4      
[51] pkgbuild_1.1.0      grid_4.0.2          blob_1.2.1          ggrepel_0.8.2       cowplot_1.1.0      
[56] haven_2.3.1         hms_0.5.3           knitr_1.30          ps_1.3.4            pillar_1.4.6       
[61] ggsignif_0.6.0      pkgload_1.1.0       reprex_0.3.0        glue_1.4.2          evaluate_0.14      
[66] data.table_1.13.0   remotes_2.2.0       BiocManager_1.30.10 modelr_0.1.8        vctrs_0.3.4        
[71] testthat_2.3.2      cellranger_1.1.0    gtable_0.3.0        assertthat_0.2.1    openxlsx_4.2.2     
[76] xfun_0.17           broom_0.7.0         rstatix_0.6.0       memoise_1.1.0       ellipsis_0.3.1     
ahorn720 commented 3 years ago

after some further digging I believe I've found where the issue is occurring.

the if/then statements within compute_CCF lead to mutmult_two_copies_entropy where at lines 14 and 15 a couple values aren't made...which are then put into the dbinom function which of course won't work without those values.

> x
── [ CNAqc ]  n = 125 mutations in 237 segments (237 clonal + 0 subclonal). Genome reference: hg38. ───────────────────

 2:0  [n = 125, L = 178 Mb] ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

ℹ Sample Purity: 80.5% ~ Ploidy: 2.
> karyotype
[1] "2:0"

>   cli::cli_rule("Computing mutation multiplicity for karyotype {.field {karyotype}} using the entropy method.")
── Computing mutation multiplicity for karyotype 2:0 using the entropy method. ────────────────────────────────────────
>   A = as.numeric(strsplit(karyotype, ":")[[1]][1])
>   B = as.numeric(strsplit(karyotype, ":")[[1]][2])
>   cl_seg = x$cna %>% dplyr::filter(CCF == 1) %>% dplyr::pull(segment_id)
>   snvs_k = x$snvs %>% dplyr::filter(karyotype == !!karyotype, 
+     segment_id %in% cl_seg)
>   expectation = CNAqc:::expected_vaf_peak(A, B, x$purity) %>% 
+     mutate(label = ifelse(mutation_multiplicity == 1, "One copy", 
+       "Two copies"))
>   med_coverage = median(snvs_k$DP, na.rm = TRUE)
>   cli::cli_alert_info("Expected Binomial peak(s) for these calls (1 and 2 copies): {.value {expectation$peak}}")
ℹ Expected Binomial peak(s) for these calls (1 and 2 copies): 
Warning message:
Unknown or uninitialised column: `peak`. 
>   p_1 = expectation$peak[1]
Warning message:
Unknown or uninitialised column: `peak`. 
>   p_2 = expectation$peak[2]
Warning message:
Unknown or uninitialised column: `peak`. 

the table expectation actually looks like this:

> expectation
# A tibble: 2 x 5
  mutation_multiplicity karyotype peak.Purity peak.Purity.1 label     
                  <dbl> <chr>           <dbl>         <dbl> <chr>     
1                     1 2:0             0.402         0.805 One copy  
2                     2 2:0             0.402         0.805 Two copies

so maybe it needs to have the column names renamed or something like that.

ahorn720 commented 3 years ago

Just thought I'd ping this comment in case it was forgotten. Thank you in advance for spending the time to work on this

luca-dex commented 3 years ago

Hi @ahorn720 thanks for pointing this out

We'll have a look

caravagn commented 3 years ago

Well this is interesting thanks @ahorn720 . I can definitely debug this for you and I am sure it must be some simple type of error. Is there any chance you could share with me the object x you pass to CNAqc ccf = compute_CCF(x)? In theory I do not all the muts, but maybe only those that generate the error (also you can anonimise your data any way you like).

caravagn commented 3 years ago

certainly peak.Purity.1 should not be there, but I need to run it line-by-line to see where that comes out from - it might be some change in the underlying managment of tibble names by tidyverse packages.

caravagn commented 3 years ago

I can say that running it on several different datasets over the last few weeks never raised this error to me, so I presume is something really simple to fix (maybe some NA where there should be none).

ahorn720 commented 3 years ago

Hi Caravagn! Sure thing. Here is a reprex::reprex of the first issue I ran into which led me to that bug.

library(CNAqc)
#> ✓ Loading CNAqc, 'Copy Number Alteration quality check'. Support : <https://caravagn.github.io/CNAqc/>
load("~/Desktop/cnaquestion.RData",verbose = T)
#> Loading objects:
#>   snvs
#>   cna
#>   purity
#>   ref

data.frame(snvs)
#>      chr      from        to          ref
#> 1   chr5 112740514 112740517            G
#> 2   chr5 112740524 112740526           CT
#> 3   chr5 112742073 112742074            A
#> 4   chr5 112742223 112742224            G
#> 5   chr5 112743064 112743065            A
#> 6   chr5 112745548 112745544         TTTA
#> 7   chr5 112745548 112745552         TTTA
#> 8   chr5 112745575 112745579            A
#> 9   chr5 112746162 112746163            A
#> 10  chr5 112747086 112747087            T
#> 11  chr5 112747109 112747110            A
#> 12  chr5 112748712 112748713            G
#> 13  chr5 112748724 112748725            G
#> 14  chr5 112748726 112748727            T
#> 15  chr5 112748928 112748929            A
#> 16  chr5 112749479 112749481           AT
#> 17  chr5 112749479 112749483           AT
#> 18  chr5 112749479 112749482           AT
#> 19  chr5 112749479 112749477           AT
#> 20  chr5 112749968 112749970            G
#> 21  chr5 112751050 112751051            C
#> 22  chr5 112753585 112753586            T
#> 23  chr5 112753783 112753784            T
#> 24  chr5 112758873 112758874            A
#> 25  chr5 112759356 112759358           CT
#> 26  chr5 112759356 112759354           CT
#> 27  chr5 112764078 112764075        TAAAA
#> 28  chr5 112764078 112764076        TAAAA
#> 29  chr5 112764245 112764247           CA
#> 30  chr5 112767811 112767812            G
#> 31  chr5 112768363 112768361           CA
#> 32  chr5 112768363 112768365           CA
#> 33  chr5 112768513 112768515           CT
#> 34  chr5 112769050 112769048         CTTT
#> 35  chr5 112769050 112769052         CTTT
#> 36  chr5 112769050 112769053         CTTT
#> 37  chr5 112769050 112769046         CTTT
#> 38  chr5 112771351 112771352            G
#> 39  chr5 112774464 112774466            A
#> 40  chr5 112774464 112774467            A
#> 41  chr5 112774464 112774468            A
#> 42  chr5 112775605 112775607            C
#> 43  chr5 112776137 112776138            C
#> 44  chr5 112776862 112776860           TA
#> 45  chr5 112778550 112778552            A
#> 46  chr5 112778550 112778553            A
#> 47  chr5 112778688 112778692            A
#> 48  chr5 112778834 112778835            C
#> 49  chr5 112781763 112781761           AT
#> 50  chr5 112781763 112781765           AT
#> 51  chr5 112783765 112783763           CA
#> 52  chr5 112783765 112783767           CA
#> 53  chr5 112783765 112783769           CA
#> 54  chr5 112783786 112783787            A
#> 55  chr5 112783796 112783790       GAAAGA
#> 56  chr5 112786886 112786884           CT
#> 57  chr5 112786886 112786888           CT
#> 58  chr5 112786905 112786901         TGAG
#> 59  chr5 112789691 112789692            A
#> 60  chr5 112789857 112789859            A
#> 61  chr5 112792467 112792468            C
#> 62  chr5 112794137 112794138            G
#> 63  chr5 112794389 112794390            C
#> 64  chr5 112799163 112799164            G
#> 65  chr5 112799183 112799185            C
#> 66  chr5 112800832 112800829          CAT
#> 67  chr5 112803976 112803977            C
#> 68  chr5 112804460 112804461            A
#> 69  chr5 112804461 112804462            T
#> 70  chr5 112804641 112804642            T
#> 71  chr5 112805008 112805006           TA
#> 72  chr5 112805530 112805531            T
#> 73  chr5 112806552 112806557    CTTTATTTA
#> 74  chr5 112806552 112806543    CTTTATTTA
#> 75  chr5 112806552 112806547    CTTTATTTA
#> 76  chr5 112809971 112809973            T
#> 77  chr5 112813752 112813754           TA
#> 78  chr5 112813752 112813750           TA
#> 79  chr5 112815564 112815565            C
#> 80  chr5 112818847 112818849            C
#> 81  chr5 112819301 112819302            G
#> 82  chr5 112819349 112819350            G
#> 83  chr5 112820182 112820179        GACAC
#> 84  chr5 112820182 112820177        GACAC
#> 85  chr5 112821030 112821032           AT
#> 86  chr5 112821030 112821028           AT
#> 87  chr5 112826600 112826597          AAC
#> 88  chr5 112828001 112828002            C
#> 89  chr5 112828457 112828455          TAA
#> 90  chr5 112828457 112828454          TAA
#> 91  chr5 112831113 112831111           AT
#> 92  chr5 112831212 112831213            G
#> 93  chr5 112833180 112833178          ATT
#> 94  chr5 112833180 112833177          ATT
#> 95  chr5 112834238 112834236           CT
#> 96  chr5 112834257 112834252        TTTTA
#> 97  chr5 112834260 112834258          TAA
#> 98  chr5 112834261 112834262            A
#> 99  chr5 112834661 112834662            G
#> 100 chr5 112835572 112835574           AT
#> 101 chr5 112836009 112836006  CTTTTTTTTTT
#> 102 chr5 112836009 112835999  CTTTTTTTTTT
#> 103 chr5 112836165 112836163          TCC
#> 104 chr5 112836165 112836162          TCC
#> 105 chr5 112836165 112836170          TCC
#> 106 chr5 112836165 112836171          TCC
#> 107 chr5 112836180 112836181            G
#> 108 chr5 112838773 112838767       TAAAAC
#> 109 chr5 112838934 112838935            C
#> 110 chr5 112839450 112839451            G
#> 111 chr5 112839474 112839475            C
#> 112 chr5 112839510 112839511            G
#> 113 chr5 112839514 112839508       TAAAAG
#> 114 chr5 112839524 112839525            G
#> 115 chr5 112839527 112839525           TG
#> 116 chr5 112839528 112839529            G
#> 117 chr5 112839558 112839559            G
#> 118 chr5 112839606 112839607            C
#> 119 chr5 112839627 112839628            G
#> 120 chr5 112839651 112839652            G
#> 121 chr5 112839693 112839694            C
#> 122 chr5 112839719 112839716          CTA
#> 123 chr5 112839720 112839718           TA
#> 124 chr5 112839722 112839717        TGTTC
#> 125 chr5 112839726 112839727            C
#> 126 chr5 112839740 112839742            C
#> 127 chr5 112839752 112839743    ATGTACTTC
#> 128 chr5 112839753 112839758            T
#> 129 chr5 112839782 112839779          TGA
#> 130 chr5 112839783 112839784            G
#> 131 chr5 112839787 112839785           GT
#> 132 chr5 112839822 112839810 TGCAGTGGAATG
#> 133 chr5 112839832 112839830           TG
#> 134 chr5 112839835 112839833           TA
#> 135 chr5 112839838 112839836           GT
#> 136 chr5 112839860 112839858           TC
#> 137 chr5 112839871 112839869           GC
#> 138 chr5 112839874 112839875            C
#> 139 chr5 112839875 112839873           TG
#> 140 chr5 112839879 112839880            C
#> 141 chr5 112839890 112839888           AC
#> 142 chr5 112839895 112839892          GCA
#> 143 chr5 112839898 112839892       GAAGTA
#> 144 chr5 112839919 112839917           CT
#> 145 chr5 112839942 112839943            C
#> 146 chr5 112840052 112840054            T
#> 147 chr5 112840054 112840052           CT
#> 148 chr5 112840056 112840053          TTA
#> 149 chr5 112840063 112840065            A
#> 150 chr5 112840072 112840070          CGG
#> 151 chr5 112840072 112840069          CGG
#> 152 chr5 112840078 112840076           GT
#> 153 chr5 112840233 112840296            G
#> 154 chr5 112840254 112840256            G
#>                                                                 alt DP NV
#> 1                                                               GTT 39  0
#> 2                                                               CTT  1  0
#> 3                                                                 G 46 42
#> 4                                                                 C 54 52
#> 5                                                                 G 34  0
#> 6                                                                 T 36  0
#> 7                                                           TTTATTA 36  0
#> 8                                                              ATTT 39 31
#> 9                                                                 G 37  0
#> 10                                                                C 38  0
#> 11                                                                G 38  0
#> 12                                                                A 34  0
#> 13                                                                C 34  0
#> 14                                                                G 34  0
#> 15                                                                G 36  0
#> 16                                                              ATT 21 19
#> 17                                                            ATTTT  2  0
#> 18                                                             ATTT  2  0
#> 19                                                                A  2  0
#> 20                                                               GT 43  0
#> 21                                                                T 36  0
#> 22                                                                C 47 38
#> 23                                                                C 42 36
#> 24                                                                G 42  0
#> 25                                                              CTT 37  0
#> 26                                                                C 37  0
#> 27                                                              TAA  0  0
#> 28                                                             TAAA 40 40
#> 29                                                              CAA  5  3
#> 30                                                                A 37  0
#> 31                                                                C 37  0
#> 32                                                              CAA 37  0
#> 33                                                              CTT 40  0
#> 34                                                              CTT  3  0
#> 35                                                            CTTTT 10  7
#> 36                                                           CTTTTT  3  0
#> 37                                                                C  3  0
#> 38                                                                T 39  0
#> 39                                                               AT  6  0
#> 40                                                              ATT 25 19
#> 41                                                             ATTT  6  0
#> 42                                                               CT 37  0
#> 43                                                                T 30  0
#> 44                                                                T 38  0
#> 45                                                               AT  6  2
#> 46                                                              ATT 26 22
#> 47                                                             AGGC 48 42
#> 48                                                                T 36  0
#> 49                                                                A 36  0
#> 50                                                              ATT 36  0
#> 51                                                                C 35  0
#> 52                                                              CAA 37  2
#> 53                                                            CAAAA 35  0
#> 54                                                                T 53  0
#> 55                                                                G 53  0
#> 56                                                                C 29  0
#> 57                                                              CTT 29  0
#> 58                                                                T 22  0
#> 59                                                                G 37  0
#> 60                                                               AT 37  0
#> 61                                                                T 36  0
#> 62                                                                A 34  0
#> 63                                                                A 61 52
#> 64                                                                A 47  0
#> 65                                                               CA 10 10
#> 66                                                                C 37  0
#> 67                                                                G 43  0
#> 68                                                                G 34  0
#> 69                                                                C 34  0
#> 70                                                                G 34  0
#> 71                                                                T 34  0
#> 72                                                                C 35  0
#> 73                                                    CTTTATTTATTTA 36  0
#> 74                                                                C 36  0
#> 75                                                            CTTTA 36  0
#> 76                                                               TG 38  0
#> 77                                                              TAA 39  0
#> 78                                                                T 39  0
#> 79                                                                T 37  0
#> 80                                                               CG 16 10
#> 81                                                                A 38  0
#> 82                                                                A 38  0
#> 83                                                              GAC 36  0
#> 84                                                                G 36  0
#> 85                                                              ATT 43  0
#> 86                                                                A 43  0
#> 87                                                                A 27  2
#> 88                                                                T 28  0
#> 89                                                               TA 36 31
#> 90                                                                T  5  0
#> 91                                                                A 39  0
#> 92                                                                A 40  0
#> 93                                                               AT 32 28
#> 94                                                                A  4  0
#> 95                                                                C 37  0
#> 96                                                                T 28  0
#> 97                                                               TA 16 15
#> 98                                                                T  1  0
#> 99                                                                A 47 41
#> 100                                                             ATT  2  0
#> 101                                                       CTTTTTTTT  0  0
#> 102                                                              CT  0  0
#> 103                                                              TC 13  0
#> 104                                                               T 13  0
#> 105                                                         TTCCCCC 13  0
#> 106                                                        TTCCCCCC 13  0
#> 107                                                               A  5  5
#> 108                                                               T 45  6
#> 109                                                               T 38  0
#> 110                                                               T 37  0
#> 111                                                               T 37  0
#> 112                                                               T 37  0
#> 113                                                               T 37 30
#> 114                                                               T 36  0
#> 115                                                               T 36  0
#> 116                                                               T 36  0
#> 117                                                               T 36  0
#> 118                                                               T 36  0
#> 119                                                               T 36  0
#> 120                                                               T 36  0
#> 121                                                               T 37  0
#> 122                                                               C 37  0
#> 123                                                               T 37  0
#> 124                                                               T 37  0
#> 125                                                               T 37  0
#> 126                                                              CA 37  0
#> 127                                                               A 37  0
#> 128                                                           TGTAC 37  0
#> 129                                                               T 37  0
#> 130                                                               T 37  0
#> 131                                                               G 37  0
#> 132                                                               T 37  0
#> 133                                                               T 37  0
#> 134                                                               T 37  0
#> 135                                                               G 37  0
#> 136                                                               T 37  0
#> 137                                                               G 37  0
#> 138                                                               T 37  0
#> 139                                                               T 37  0
#> 140                                                               T 37  0
#> 141                                                               A 37  0
#> 142                                                               G 37  0
#> 143                                                               G 37  0
#> 144                                                               C 37  0
#> 145                                                               T 37  0
#> 146                                                              TA 36  0
#> 147                                                               C 36  0
#> 148                                                               T 36  0
#> 149                                                              AT 36  0
#> 150                                                              CG 36  0
#> 151                                                               C 36  0
#> 152                                                               G 37  0
#> 153 GCTGGCATCTGGATTTCAGACTTCTGGCTTCCAGAACTGTGGAAGAAGACATCTCGTTGTTTT 35  0
#> 154                                                              GA 35  0
#>            VAF  Samples
#> 1   0.00000000 A002C204
#> 2   0.00000000 A002C204
#> 3   0.91304348 A002C204
#> 4   0.96296296 A002C204
#> 5   0.00000000 A002C204
#> 6   0.00000000 A002C204
#> 7   0.00000000 A002C204
#> 8   0.79487179 A002C204
#> 9   0.00000000 A002C204
#> 10  0.00000000 A002C204
#> 11  0.00000000 A002C204
#> 12  0.00000000 A002C204
#> 13  0.00000000 A002C204
#> 14  0.00000000 A002C204
#> 15  0.00000000 A002C204
#> 16  0.90476190 A002C204
#> 17  0.00000000 A002C204
#> 18  0.00000000 A002C204
#> 19  0.00000000 A002C204
#> 20  0.00000000 A002C204
#> 21  0.00000000 A002C204
#> 22  0.80851064 A002C204
#> 23  0.85714286 A002C204
#> 24  0.00000000 A002C204
#> 25  0.00000000 A002C204
#> 26  0.00000000 A002C204
#> 27  0.00000000 A002C204
#> 28  1.00000000 A002C204
#> 29  0.60000000 A002C204
#> 30  0.00000000 A002C204
#> 31  0.00000000 A002C204
#> 32  0.00000000 A002C204
#> 33  0.00000000 A002C204
#> 34  0.00000000 A002C204
#> 35  0.70000000 A002C204
#> 36  0.00000000 A002C204
#> 37  0.00000000 A002C204
#> 38  0.00000000 A002C204
#> 39  0.00000000 A002C204
#> 40  0.76000000 A002C204
#> 41  0.00000000 A002C204
#> 42  0.00000000 A002C204
#> 43  0.00000000 A002C204
#> 44  0.00000000 A002C204
#> 45  0.33333333 A002C204
#> 46  0.84615385 A002C204
#> 47  0.87500000 A002C204
#> 48  0.00000000 A002C204
#> 49  0.00000000 A002C204
#> 50  0.00000000 A002C204
#> 51  0.00000000 A002C204
#> 52  0.05405405 A002C204
#> 53  0.00000000 A002C204
#> 54  0.00000000 A002C204
#> 55  0.00000000 A002C204
#> 56  0.00000000 A002C204
#> 57  0.00000000 A002C204
#> 58  0.00000000 A002C204
#> 59  0.00000000 A002C204
#> 60  0.00000000 A002C204
#> 61  0.00000000 A002C204
#> 62  0.00000000 A002C204
#> 63  0.85245902 A002C204
#> 64  0.00000000 A002C204
#> 65  1.00000000 A002C204
#> 66  0.00000000 A002C204
#> 67  0.00000000 A002C204
#> 68  0.00000000 A002C204
#> 69  0.00000000 A002C204
#> 70  0.00000000 A002C204
#> 71  0.00000000 A002C204
#> 72  0.00000000 A002C204
#> 73  0.00000000 A002C204
#> 74  0.00000000 A002C204
#> 75  0.00000000 A002C204
#> 76  0.00000000 A002C204
#> 77  0.00000000 A002C204
#> 78  0.00000000 A002C204
#> 79  0.00000000 A002C204
#> 80  0.62500000 A002C204
#> 81  0.00000000 A002C204
#> 82  0.00000000 A002C204
#> 83  0.00000000 A002C204
#> 84  0.00000000 A002C204
#> 85  0.00000000 A002C204
#> 86  0.00000000 A002C204
#> 87  0.07407407 A002C204
#> 88  0.00000000 A002C204
#> 89  0.86111111 A002C204
#> 90  0.00000000 A002C204
#> 91  0.00000000 A002C204
#> 92  0.00000000 A002C204
#> 93  0.87500000 A002C204
#> 94  0.00000000 A002C204
#> 95  0.00000000 A002C204
#> 96  0.00000000 A002C204
#> 97  0.93750000 A002C204
#> 98  0.00000000 A002C204
#> 99  0.87234043 A002C204
#> 100 0.00000000 A002C204
#> 101 0.00000000 A002C204
#> 102 0.00000000 A002C204
#> 103 0.00000000 A002C204
#> 104 0.00000000 A002C204
#> 105 0.00000000 A002C204
#> 106 0.00000000 A002C204
#> 107 1.00000000 A002C204
#> 108 0.13333333 A002C204
#> 109 0.00000000 A002C204
#> 110 0.00000000 A002C204
#> 111 0.00000000 A002C204
#> 112 0.00000000 A002C204
#> 113 0.81081081 A002C204
#> 114 0.00000000 A002C204
#> 115 0.00000000 A002C204
#> 116 0.00000000 A002C204
#> 117 0.00000000 A002C204
#> 118 0.00000000 A002C204
#> 119 0.00000000 A002C204
#> 120 0.00000000 A002C204
#> 121 0.00000000 A002C204
#> 122 0.00000000 A002C204
#> 123 0.00000000 A002C204
#> 124 0.00000000 A002C204
#> 125 0.00000000 A002C204
#> 126 0.00000000 A002C204
#> 127 0.00000000 A002C204
#> 128 0.00000000 A002C204
#> 129 0.00000000 A002C204
#> 130 0.00000000 A002C204
#> 131 0.00000000 A002C204
#> 132 0.00000000 A002C204
#> 133 0.00000000 A002C204
#> 134 0.00000000 A002C204
#> 135 0.00000000 A002C204
#> 136 0.00000000 A002C204
#> 137 0.00000000 A002C204
#> 138 0.00000000 A002C204
#> 139 0.00000000 A002C204
#> 140 0.00000000 A002C204
#> 141 0.00000000 A002C204
#> 142 0.00000000 A002C204
#> 143 0.00000000 A002C204
#> 144 0.00000000 A002C204
#> 145 0.00000000 A002C204
#> 146 0.00000000 A002C204
#> 147 0.00000000 A002C204
#> 148 0.00000000 A002C204
#> 149 0.00000000 A002C204
#> 150 0.00000000 A002C204
#> 151 0.00000000 A002C204
#> 152 0.00000000 A002C204
#> 153 0.00000000 A002C204
#> 154 0.00000000 A002C204
data.frame(cna)
#>     chr      from        to Major minor  Samples
#> 1     1    822668   1985814     1     1 A002C204
#> 2     1   1985815   2008141     2     2 A002C204
#> 3     1   2008142  13911153     1     1 A002C204
#> 4     1  13911154  13959414     3     0 A002C204
#> 5     1  13959415 121764540     1     1 A002C204
#> 6     1 121764541 121782089     2     0 A002C204
#> 7     1 121782090 122632098     2     1 A002C204
#> 8     1 122632099 122684264     2     0 A002C204
#> 9     1 122684265 123395250     2     1 A002C204
#> 10    1 123395251 123409594     4     0 A002C204
#> 11    1 123409595 123764103     2     1 A002C204
#> 12    1 123764104 124909534     3     1 A002C204
#> 13    1 124909535 125073299     1     1 A002C204
#> 14    1 125073300 125115406     2     0 A002C204
#> 15    1 125115407 134442991     2     1 A002C204
#> 16    1 134442992 153687686     1     1 A002C204
#> 17    1 153687687 153725910     2     1 A002C204
#> 18    1 153725911 160695304     1     1 A002C204
#> 19    1 160695305 160697028     2     0 A002C204
#> 20    1 160697029 234775059     1     1 A002C204
#> 21    1 234775060 234782142     3     1 A002C204
#> 22    1 234782143 248903660     1     1 A002C204
#> 23    2     10797  89353653     1     1 A002C204
#> 24    2  89353654  89958704     2     1 A002C204
#> 25    2  89958705  90807134     1     1 A002C204
#> 26    2  90807135  94158750     2     1 A002C204
#> 27    2  94158751 240879852     1     1 A002C204
#> 28    2 240879853 240883002     2     2 A002C204
#> 29    2 240883003 242058566     1     1 A002C204
#> 30    3     57400  90748398     1     1 A002C204
#> 31    3  90748399  93254302     2     1 A002C204
#> 32    3  93254303 190199629     1     1 A002C204
#> 33    3 190199630 190202394     5     3 A002C204
#> 34    3 190202395 195697804     1     1 A002C204
#> 35    3 195697805 195711892     2     1 A002C204
#> 36    3 195711893 198113136     1     1 A002C204
#> 37    4     85866  42771923     1     1 A002C204
#> 38    4  42771924  42773322     2     0 A002C204
#> 39    4  42773323  49360128     1     1 A002C204
#> 40    4  49360129  49640652     4     0 A002C204
#> 41    4  49640653  50512170     2     1 A002C204
#> 42    4  50512171 188504076     1     1 A002C204
#> 43    4 188504077 188507054     1     0 A002C204
#> 44    4 188507055 189872692     1     1 A002C204
#> 45    5     12041  46512789     2     0 A002C204
#> 46    5  46512790  50148080     2     1 A002C204
#> 47    5  50148081 159916549     2     0 A002C204
#> 48    5 159916550 159924351     1     1 A002C204
#> 49    5 159924352 175911088     2     0 A002C204
#> 50    5 175911089 176032464     1     1 A002C204
#> 51    5 176032465 181271629     2     0 A002C204
#> 52    6    171649    250034     1     1 A002C204
#> 53    6    250035    382392     2     1 A002C204
#> 54    6    382393  35781648     1     1 A002C204
#> 55    6  35781649  35799023     2     1 A002C204
#> 56    6  35799024  60232108     1     1 A002C204
#> 57    6  60232109  60235249     2     0 A002C204
#> 58    6  60235250 155026833     1     1 A002C204
#> 59    6 155026834 155029916     4     4 A002C204
#> 60    6 155029917 170597327     1     1 A002C204
#> 61    7     41888  62342668     2     1 A002C204
#> 62    7  62342669  62343413     2     0 A002C204
#> 63    7  62343414  81358228     2     1 A002C204
#> 64    7  81358229  81359971     2     0 A002C204
#> 65    7  81359972 100952610     2     1 A002C204
#> 66    7 100952611 100961172     3     1 A002C204
#> 67    7 100961173 144779724     2     1 A002C204
#> 68    7 144779725 144781900     4     4 A002C204
#> 69    7 144781901 159329969     2     1 A002C204
#> 70    8    220692   6957548     1     1 A002C204
#> 71    8   6957549   8646974     2     1 A002C204
#> 72    8   8646975   8824464     1     1 A002C204
#> 73    8   8824465   8948930     2     1 A002C204
#> 74    8   8948931   9069558     1     1 A002C204
#> 75    8   9069559   9243576     2     1 A002C204
#> 76    8   9243577   9370558     1     1 A002C204
#> 77    8   9370559   9456231     2     1 A002C204
#> 78    8   9456232  13032581     1     1 A002C204
#> 79    8  13032582  13053099     2     1 A002C204
#> 80    8  13053100  21760352     1     1 A002C204
#> 81    8  21760353  22099509     2     1 A002C204
#> 82    8  22099510  22725141     1     1 A002C204
#> 83    8  22725142  22990366     2     1 A002C204
#> 84    8  22990367  25038967     1     1 A002C204
#> 85    8  25038968  25158108     2     1 A002C204
#> 86    8  25158109  25927974     1     1 A002C204
#> 87    8  25927975  26226254     2     1 A002C204
#> 88    8  26226255  37523720     1     1 A002C204
#> 89    8  37523721  38597754     2     1 A002C204
#> 90    8  38597755  39994712     1     1 A002C204
#> 91    8  39994713  40269844     2     1 A002C204
#> 92    8  40269845  41334544     1     1 A002C204
#> 93    8  41334545  41476523     2     1 A002C204
#> 94    8  41476524  42102888     1     1 A002C204
#> 95    8  42102889  42783768     2     1 A002C204
#> 96    8  42783769  69844424     1     1 A002C204
#> 97    8  69844425  70021513     2     1 A002C204
#> 98    8  70021514  72181818     1     1 A002C204
#> 99    8  72181819  72183076     4     2 A002C204
#> 100   8  72183077  80155517     1     1 A002C204
#> 101   8  80155518  80592485     2     1 A002C204
#> 102   8  80592486  94620405     1     1 A002C204
#> 103   8  94620406  94966532     2     1 A002C204
#> 104   8  94966533  97433968     1     1 A002C204
#> 105   8  97433969  97819902     2     1 A002C204
#> 106   8  97819903 102421227     1     1 A002C204
#> 107   8 102421228 102715420     2     1 A002C204
#> 108   8 102715421 119841344     1     1 A002C204
#> 109   8 119841345 120159806     2     1 A002C204
#> 110   8 120159807 125243048     1     1 A002C204
#> 111   8 125243049 125481604     2     1 A002C204
#> 112   8 125481605 127589052     1     1 A002C204
#> 113   8 127589053 127828578     2     1 A002C204
#> 114   8 127828579 133533319     1     1 A002C204
#> 115   8 133533320 133704132     2     1 A002C204
#> 116   8 133704133 139996605     1     1 A002C204
#> 117   8 139996606 142188974     2     1 A002C204
#> 118   8 142188975 142379368     1     1 A002C204
#> 119   8 142379369 142657086     2     1 A002C204
#> 120   8 142657087 142837858     1     1 A002C204
#> 121   8 142837859 143521131     2     1 A002C204
#> 122   8 143521132 143617574     1     1 A002C204
#> 123   8 143617575 144962821     2     1 A002C204
#> 124   8 144962822 145071631     1     1 A002C204
#> 125   9    204014  39180130     1     1 A002C204
#> 126   9  39180131  40912086     2     1 A002C204
#> 127   9  40912087  40915793     2     0 A002C204
#> 128   9  40915794  62869874     2     1 A002C204
#> 129   9  62869875 129404868     1     1 A002C204
#> 130   9 129404869 129485292     2     1 A002C204
#> 131   9 129485293 138124865     1     1 A002C204
#> 132  10     91366  38242652     1     1 A002C204
#> 133  10  38242653  38522852     2     1 A002C204
#> 134  10  38522853  38690962     1     1 A002C204
#> 135  10  38690963  38813996     2     1 A002C204
#> 136  10  38813997  38816054     2     0 A002C204
#> 137  10  38816055  38941858     2     1 A002C204
#> 138  10  38941859  39571988     1     1 A002C204
#> 139  10  39571989  41522648     2     1 A002C204
#> 140  10  41522649  41530557     2     0 A002C204
#> 141  10  41530558  41649224     2     1 A002C204
#> 142  10  41649225  42231738     1     1 A002C204
#> 143  10  42231739  42303078     2     0 A002C204
#> 144  10  42303079  46522963     1     1 A002C204
#> 145  10  46522964  46541968     2     1 A002C204
#> 146  10  46541969 108547330     1     1 A002C204
#> 147  10 108547331 108549138     5     3 A002C204
#> 148  10 108549139 133622305     1     1 A002C204
#> 149  11    196944  51155272     1     1 A002C204
#> 150  11  51155273  54545390     2     1 A002C204
#> 151  11  54545391 135075590     1     1 A002C204
#> 152  12     21064     38052     1     1 A002C204
#> 153  12     38053     70274     2     1 A002C204
#> 154  12     70275  34801010     1     1 A002C204
#> 155  12  34801011  37262642     2     1 A002C204
#> 156  12  37262643 133240522     1     1 A002C204
#> 157  13  16003441  38955993     2     1 A002C204
#> 158  13  38955994  38956733     6     2 A002C204
#> 159  13  38956734 114328229     2     1 A002C204
#> 160  14  16097169  16109122     1     0 A002C204
#> 161  14  16109123  16137230     2     1 A002C204
#> 162  14  16137231  17181838     3     1 A002C204
#> 163  14  17181839 106874228     1     1 A002C204
#> 164  15  17009590  17021518     1     1 A002C204
#> 165  15  17021519  17030497     3     0 A002C204
#> 166  15  17030498  22024845     2     1 A002C204
#> 167  15  22024846  57762495     1     1 A002C204
#> 168  15  57762496  57763216     3     0 A002C204
#> 169  15  57763217 101633478     1     1 A002C204
#> 170  16     46987  16414866     1     1 A002C204
#> 171  16  16414867  16700565     2     1 A002C204
#> 172  16  16700566  22504980     1     1 A002C204
#> 173  16  22504981  22699922     2     1 A002C204
#> 174  16  22699923  36277740     1     1 A002C204
#> 175  16  36277741  46428446     2     1 A002C204
#> 176  16  46428447  70046418     1     1 A002C204
#> 177  16  70046419  70229015     2     1 A002C204
#> 178  16  70229016  90051298     1     1 A002C204
#> 179  17    143015  12650427     1     1 A002C204
#> 180  17  12650428  12653101     4     4 A002C204
#> 181  17  12653102  21751028     1     1 A002C204
#> 182  17  21751029  21855518     2     1 A002C204
#> 183  17  21855519  21858186     2     0 A002C204
#> 184  17  21858187  22726028     1     1 A002C204
#> 185  17  22726029  26769088     2     1 A002C204
#> 186  17  26769089  26836150     2     0 A002C204
#> 187  17  26836151  83204151     1     1 A002C204
#> 188  18    132671  15195206     1     1 A002C204
#> 189  18  15195207  20874209     2     1 A002C204
#> 190  18  20874210  61969008     1     1 A002C204
#> 191  18  61969009  61971189     4     3 A002C204
#> 192  18  61971190  80248182     1     1 A002C204
#> 193  19    263280   1524112     2     1 A002C204
#> 194  19   1524113   1775290     3     2 A002C204
#> 195  19   1775291   8097458     2     1 A002C204
#> 196  19   8097459   8268512     3     2 A002C204
#> 197  19   8268513  24369446     2     1 A002C204
#> 198  19  24369447  24896730     3     1 A002C204
#> 199  19  24896731  24897864     3     0 A002C204
#> 200  19  24897865  27242278     3     1 A002C204
#> 201  19  27242279  27354712     2     1 A002C204
#> 202  19  27354713  27407438     3     1 A002C204
#> 203  19  27407439  58580561     2     1 A002C204
#> 204  20     61083  26331013     1     1 A002C204
#> 205  20  26331014  26345356     2     0 A002C204
#> 206  20  26345357  28784970     2     1 A002C204
#> 207  20  28784971  28826332     2     0 A002C204
#> 208  20  28826333  28886948     2     1 A002C204
#> 209  20  28886949  28904928     2     0 A002C204
#> 210  20  28904929  30064009     2     1 A002C204
#> 211  20  30064010  64281506     1     1 A002C204
#> 212  21   7324287   7325448     2     1 A002C204
#> 213  21   7325449   7325732     2     0 A002C204
#> 214  21   7325733   7326344     2     1 A002C204
#> 215  21   7326345   7919116     2     0 A002C204
#> 216  21   7919117   7925434     3     1 A002C204
#> 217  21   7925435   7954084     2     0 A002C204
#> 218  21   7954085  10701814     3     1 A002C204
#> 219  21  10701815  10702238     2     0 A002C204
#> 220  21  10702239  10705696     2     1 A002C204
#> 221  21  10705697  10705967     2     0 A002C204
#> 222  21  10705968  10758066     3     1 A002C204
#> 223  21  10758067  10758828     2     0 A002C204
#> 224  21  10758829  10784464     2     1 A002C204
#> 225  21  10784465  11889812     3     1 A002C204
#> 226  21  11889813  13493784     2     1 A002C204
#> 227  21  13493785  46672164     1     1 A002C204
#> 228  22  11219527  12401808     2     1 A002C204
#> 229  22  12401809  12402615     2     0 A002C204
#> 230  22  12402616  12423085     2     1 A002C204
#> 231  22  12423086  22584056     1     1 A002C204
#> 232  22  22584057  22587092     2     2 A002C204
#> 233  22  22587093  40151354     1     1 A002C204
#> 234  22  40151355  40171254     2     2 A002C204
#> 235  22  40171255  44414652     1     1 A002C204
#> 236  22  44414653  44449100     2     1 A002C204
#> 237  22  44449101  50736234     1     1 A002C204
data.frame(purity)
#>   Purity
#> 1  0.805
x = init(snvs,
         cna,
         purity,
         ref = "hg38")
#>  [ CNAqc - CNA Quality Check ]
#> ℹ Using reference genome coordinates for: hg38.
#> Warning in fortify_mutation_calls(snvs): You are using indels mutation data,
#> just beware that indels count-values aree less reliable than SNVs ones ....
#> ! Missing CCF column from CNA calls, adding CCF = 1 assuming clonal CNA calls.
#> ! Missing segments length from CNA calls, adding it to CNA calls.
#> ! CNA chromosomes should be in the format 'chr*', I will add a 'chr' prefix.
#> ℹ Input n = 154 mutations for 237 CNA segments (237 clonal, 0 subclonal)
#> ✓ Mapped n = 154 mutations to clonal segments (100% of input)

snvs.samp = x$snvs

cna.samp = x$cna

pure.samp = x$purity
ccf = compute_CCF(x)
#> ── Computing mutation multiplicity for karyotype 2:0 using the entropy method. ─
#> ℹ Expected Binomial peak(s) for these calls (1 and 2 copies):
#> Error in dbinom(NV, size = n, prob = p): Non-numeric argument to mathematical function
ccf.data = CCF(ccf)
#> Error in CCF(ccf): inherits(x, "cnaqc") is not TRUE
ccf.data$CCF[ccf.data$CCF>=1] = 1
#> Error in ccf.data$CCF[ccf.data$CCF >= 1] = 1: object 'ccf.data' not found
ccfs[[sample]] = ccf.data  
#> Error in eval(expr, envir, enclos): object 'ccf.data' not found

Created on 2020-11-17 by the reprex package (v0.3.0.9001)

Thank you very much. Please let me know if you need any more details.

caravagn commented 3 years ago

The reprex is clear, thanks, and I should be able to fix it -- maybe is the fact that some mutations have 0 DP and 0 VAF and you get some NA somewhere? Btw, could you link here file "~/Desktop/cnaquestion.RData" so I can avoid copy-pasting from this shell and parsing the input?

caravagn commented 3 years ago

Sending it to gcaravagn@gmail.com would work too - thanks.

ahorn720 commented 3 years ago

Though this shows up as a comment…this is an email to the email yoou posted below too with that linked file

Thank you!

On Nov 17, 2020, at 2:29 PM, Giulio Caravagna notifications@github.com wrote:

Sending it to gcaravagn@gmail.com mailto:gcaravagn@gmail.com would work too - thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/caravagn/CNAqc/issues/4#issuecomment-729252682, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABY3HY77S4WRUD7COBRGHI3SQL2OBANCNFSM4TQAQ5IQ.

ahorn720 commented 3 years ago

From whaat I could tell it had to do with the Karyotype being 2:0 for this set of mutations. In this dataset, all the mutations are from a single gene which are from a single segment which inn this case is 2:0.

But of course I’ll defer to your expertise on the software. Thats just what I could determine from my little investigation.

I look forward to seeing what the issue was.

I may have another issue in the future too but one thing at a time :)

On Nov 17, 2020, at 2:29 PM, Giulio Caravagna notifications@github.com wrote:

The reprex is clear, thanks, and I should be able to fix it -- maybe is the fact that some mutations have 0 DP and 0 VAF and you get some NA somewhere? Btw, could you link here file "~/Desktop/cnaquestion.RData" so I can avoid copy-pasting from this shell and parsing the input?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/caravagn/CNAqc/issues/4#issuecomment-729252363, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABY3HY7G7MOSSVQRX26NI7DSQL2LHANCNFSM4TQAQ5IQ.

caravagn commented 3 years ago

Hey, I've fixed it. There was a problem for a weird case I did not consider. Now it works and computes CCF for your data. Thanks (PS I did improve some other visualisations etc.)

caravagn commented 3 years ago

See [4a1d37f]