Hello,
I am trying to run SomaticSignatures package but I can't get the input file (a VRange object) right.
In the examples given by their vignette is this:
>sca_vr = VRanges(
seqnames = seqnames(sca_data),
ranges = ranges(sca_data),
ref = sca_data$Reference_Allele,
alt = sca_data$Tumor_Seq_Allele2,
sampleNames = sca_data$Patient_ID,
seqinfo = seqinfo(sca_data),
study = sca_data$study)
But when I try to use exactly the same code with my data, that I pulled from a vcf example, provided but the VariantAnnotation package, I am unable to obtain the same VRange object:
> test_range=VRanges(
+ seqnames = seqnames(vcfRange),
+ ranges = ranges(vcfRange),
+ ref = vcfRange$REF,
+ alt = vcfRange$ALT)
Error in as.vector(x, mode = "character") :
no method for coercing this S4 class to a vector
This is how I obtained the vcf example:
>library(VariantAnnotation) #load the package
>fl <- system.file("extdata", "chr22.vcf.gz", package="VariantAnnotation") #folder
>vcf <- readVcf(fl, "hg19") #input vcf
>vcfRange=rowRanges(vcf)
Can anyone help me to figure this out? Thanks
Yeas... I had noticed that. There is a list instead of a vector in the ALT allele, but I didn't know why exactly. I'll try to extract this as a vector using only the first one. Thanks
Thank you so much. It worked with unlist(vcfRange$ALT)
Thank you so much. It worked with unlist(vcfRange$ALT)
Yes, that works in this instance, where the DNAStringSetList for the ALT allele has only one allele per position. But if that isn't true, then it doesn't work
A (probably naive) way to get around that is to just use the first element in any list item that is longer than 1. There are most assuredly better ways of doing this, (and probably Martin Morgan or Michael Lawrence will be along shortly to show how), but a quick solution is