caravagnalab / CNAqc

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

group_by function error #17

Closed Taekya closed 2 years ago

Taekya commented 2 years ago

Hello, An error occurred when executing the function as shown below. group_by function error occurs in the run_2 step after the run_1 step is completed. When executing the code manually, an error occurred CNAqc::init(snvs = mutations, cna = fits$segments, purity = fits$purity, ref = reference) %>% analyze_peaks(). group_by error occurred when executing the x$peaks_analysis$general$analysis = analysis script when executing analyze_peaks_common function in analyze_peaks function. how to fix this error?

Sequenza_CNAqc(sample_id=sample, 
               seqz_file=paste0(sequenza_dir,'/', sample, "-dedup.small.seqz.gz"), 
               mutations=sample_mutations[[1]],
               sex='F', reference='hg19')
ℹ Quality control with CNAqc: run_2
 [ CNAqc - CNA Quality Check ] 

ℹ Using reference genome coordinates for: hg19.
! Detected indels mutation; do not forget to rely more on SNVs for data QC.
✔ Fortified calls for 12842 somatic mutations: 12113 SNVs (94%) and 729 indels.
! CNAs have no CCF, assuming clonal CNAs (CCF = 1).
! Added segments length (in basepairs) to CNA segments.
✔ Fortified CNAs for 49 segments: 49 clonal and 0 subclonal.
✔ 12822 mutations mapped to clonal CNAs.

── Peak analysis: simple CNAs ──────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Quality control with CNAqc: run_2
! No karyotypes satisfy input data filters.

── Peak analysis: complex CNAs ─────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Quality control with CNAqc: run_2
ℹ Karyotypes 3:3, 3:0, 4:0, 4:3, 4:4, 3:2, and 5:2 with >100 mutation(s). Using epsilon = 0.05.
# A tibble: 7 × 5 with CNAqc: run_2
# Groups:   karyotype, matched [7]
  karyotype n       mismatched matched  prop
  <chr>     <table>      <int>   <dbl> <dbl>
1 4:3        810             2       2 0.5  
2 4:4        429             2       2 0.5  
3 5:2        262             3       2 0.4  
4 3:0       2435             2       1 0.333
5 3:2        398             2       1 0.333
6 3:3       7369             2       1 0.333
7 4:0       1056             4       0 0    

── Peak analysis: subclonal CNAs ───────────────────────────────────────────────────────────────────────────────────────────────
ℹ Quality control with CNAqc: run_2
ℹ No subclonal CNAs in this sample. 
── [ CNAqc ]  12822 mutations in 49 segments (49 clonal, 0 subclonal). Genome reference: hg19. ─────────────────────────────────

── Clonal CNAs                      
ℹ Quality control with CNAqc: run_2
 3:3  [n = 7369, L = 1573 Mb] ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
 3:0  [n = 2435, L =  547 Mb] ■■■■■■■■■■■■■■
 4:0  [n = 1056, L =  254 Mb] ■■■■■■
 4:3  [n =  810, L =  171 Mb] ■■■■■
 4:4  [n =  429, L =   98 Mb] ■■
 3:2  [n =  398, L =   83 Mb] ■■
 5:2  [n =  262, L =   92 Mb] ■■
 6:1  [n =   63, L =   19 Mb] 

ℹ Sample Purity: 62.1717171717172% ~ Ploidy: 6.
ℹ Quality control with CNAqc: run_2
Error in UseMethod("group_by") : 
  no applicable method for 'group_by' applied to an object of class "NULL"
In addition: Warning messages:
1: In dir.create(out_dir) : 'run_1' already exists
2: In dir.create(out_dir) :

Error in UseMethod("group_by") :
no applicable method for 'group_by' applied to an object of class "NULL"
11.dplyr::group_by(., QC)
10.dplyr::summarise(., prop = sum(weight), .groups = "drop")
9.dplyr::arrange(., desc(prop))
8.dplyr::filter(., dplyr::row_number() == 1)
7.dplyr::pull(., prop)
6.x$peaks_analysis$matches %>% dplyr::group_by(QC) %>% dplyr::summarise(prop = sum(weight),
.groups = "drop") %>% dplyr::arrange(desc(prop)) %>% dplyr::filter(dplyr::row_number() ==
1) %>% dplyr::pull(prop)
5.print.cnaqc(cnaqc_obj)
4.print(cnaqc_obj)
3.print(cnaqc_obj) at sequenza_cnaqc_function.R#223
2.sequenza_fit_runner(seqzExt, mutations, run = run_index, is_female,
cellularity, ploidy, sample_id, out_dir = paste0("run_",
run_index), reference = reference) at sequenza_cnaqc_function.R#77
1.Sequenza_CNAqc(sample_id = sample, seqz_file = paste0(sequenza_dir,
"/", sample, "-dedup.small.seqz.gz"), mutations = sample_mutations[[1]],
sex = "F", reference = "hg19")

✖ Quality control with CNAqc: run_2 ... failed
caravagn commented 2 years ago

Hi, I pass this along to @nicola-calonaci since he developed Sequenza_CNAqc. As gut feeling I am afraid it crashes because there are no simple CNAs in this sample - a trivial bug to fix. Is there any way you can share a dummy version of your object CNAqc::init(snvs = mutations, cna = fits$segments, purity = fits$purity, ref = reference) so that we can reproduce the bug?

caravagn commented 2 years ago

I will close this issue since there was no reply from @Taekya.