Bioconductor / VariantAnnotation

Annotation of Genetic Variants
https://bioconductor.org/packages/VariantAnnotation
26 stars 20 forks source link

add a GENO field #9

Closed tdelhomme closed 5 years ago

tdelhomme commented 6 years ago

Hi,

I would like to add a GENO field in my VCF (CollapsedVCF object), so here is what I did:

geno(header(vcf_chunk))["addCov",]=list("1","Integer","Added coverage from external table")
covs = matrix(...) #here I have the correct format with same rownames and colnames as other GENO fields
geno(vcf_chunk[1,])[["addCov"]] = covs

and I get this:

Warning message:
In .Method(..., FUN = FUN, MoreArgs = MoreArgs, SIMPLIFY = SIMPLIFY,  :
  longer argument not a multiple of length of shorter

It seems that this create an "NA" field in the GENO, and I can not change this into my true name:

names(geno(vcf_chunk[i,]))[14]="addCov"
names(geno(vcf_chunk[i,]))[14]
[1] NA
vobencha commented 5 years ago

@tdelhomme Sorry it took awhile for me to get to this. You say covs object has the correct dimensions but it would still be helpful to see it. Here is an example of adding a new geno field where the replacement has the correct number of rows/columns:

> example(readVcf)
> geno(vcf)
List of length 1
names(1): HQ
> geno(vcf)$HQ
, , 1

               NA00001 NA00002 NA00003
rs6054257           51      51      NA
20:17330_T/A        58      65      NA
rs6040355           23      18      NA
20:1230237_T/.      56      51      NA
microsat1           NA      NA      NA

, , 2

               NA00001 NA00002 NA00003
rs6054257           51      51      NA
20:17330_T/A        50       3      NA
rs6040355           27       2      NA
20:1230237_T/.      60      51      NA
microsat1           NA      NA      NA

> geno(vcf)$newField <- matrix(1:15, nrow=5)
Warning message:
geno fields with no header: newField 
> geno(vcf)
List of length 2
names(2): HQ newField

If you're still having this problem, please show what covs looks like or provide a reproducible example. Also post your sessionInfo().

Thanks. Valerie

tdelhomme commented 5 years ago

Hi @vobencha, Thanks a lot for your answer, will give a try asap and let you know what I get!

vobencha commented 5 years ago

Closing this issue. If you have other problems using the package please post on the support site (https://support.bioconductor.org/) or bioc-devel@r-project.org.