jpuntomarcos / CNVfilteR

R package to remove false positives of CNV calling tools by using SNV calls
5 stars 1 forks source link

Getting Error in normarg_mcols() when attempting to loadSNPsFromVCF() #14

Closed CNHAustin closed 2 months ago

CNHAustin commented 2 months ago

Hello,

First of all, thanks so much for this great tool. I love the vignette and the paper. Very elegant.

Issue

I am getting the following error when running the loadSNPsFromVCF() function below:

Code:

vcfs <- loadVCFs("./example.vcf", cnvs.gr = cnvs.gr, genome = "hg38", sample.names = "example", ref.support.field = "AD", alt.support.field = "AD", exclude.non.canonical.chrs = TRUE, verbose = TRUE)

Error:

Error in normarg_mcols(value, class(x), length(x)) : 
  trying to set metadata columns of length 2 on an object of length 1

8. stop(wmsg("trying to set ", if (one) "a " else "", "metadata column",
if (one) "" else "s", " ", "of length ", mcols_nrow, " on an object of length ",
x_len))

7. normarg_mcols(value, class(x), length(x))

6. `elementMetadata<-`(x, ..., value = value)

5. `elementMetadata<-`(x, ..., value = value)

4. GenomicRanges::`mcols<-`(`*tmp*`, value = mdata)

3. GenomicRanges::`mcols<-`(`*tmp*`, value = mdata)

2. loadSNPsFromVCF(vcf.file = vcfFile, verbose = verbose, vcf.source = vcf.source,
ref.support.field = ref.support.field, alt.support.field = alt.support.field,
list.support.field = list.support.field, regions.to.filter = cnvs.gr,
genome = genome, exclude.non.canonical.chrs = exclude.non.canonical.chrs)

1. loadVCFs("./example.vcf", cnvs.gr = cnvs.gr, genome = "hg38",
sample.names = "example", ref.support.field = "AD", alt.support.field = "AD",
exclude.non.canonical.chrs = TRUE, verbose = TRUE)

Loading the SNVs appears to work until variant entry 26081:

chr1    13225208    .   C   G   18.67   PASS    AC=1;AF=0.5;AN=2;DP=66;FS=13.294;MQ=122.45;MQRankSum=0.824;QD=0.28;ReadPosRankSum=3.561;SOR=1.589;FractionInformativeReads=1    GT:AD:AF:DP:F1R2:F2R1:GQ:PL:GP:PRI:SB:MB    0/1:28,38:0.5758:66:11,20:17,18:17:53,0,18:18.67,0.09275,21.222:0,34.77,37.78:12,16,26,12:15,13,22,16

But all variants before it appear to have the same formatting. I can't identify why this line is giving the function issues. Here's the entry just before it (26080):

chr1    13225325    .   T   C   22.12   PASS    AC=1;AF=0.5;AN=2;DP=50;FS=6.716;MQ=88.21;MQRankSum=3.735;QD=0.44;ReadPosRankSum=4.167;SOR=1.768;FractionInformativeReads=1  GT:AD:AF:DP:F1R2:F2R1:GQ:PL:GP:PRI:SB:MB    0/1:21,29:0.58:50:11,13:8,16:17:57,0,16:22.118,0.080212,19.151:0,34.77,37.78:8,13,6,23:10,11,20,9

Any ideas where to go from here?

Thanks, Austin

CNHAustin commented 2 months ago

AH! Solved my own issue. Because my Allele Depth being in a list format, I should have used the list.support.field parameter. Like so:

vcfs <- loadVCFs("./example.vcf", cnvs.gr = cnvs.gr, genome = "hg38", sample.names = "example", list.support.field = "AD", exclude.non.canonical.chrs = TRUE, verbose = TRUE)