It worked, Thank you very much!
• 0 views
•
link
Hello,
I have cell free DNA of 5 samples in VCF file format, I want to plot the shared variants between all the samples in an Upset plot. Which parameters do I need to consider as input and how to convert them into binary format. I have converted my files into tsv format.
This is the header of my VCF file:
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT S1_P-gDNA S1_P-cfDNA NORMAL cfDNA
Could some one please help with this?
Thanks.
Try this example:
library(UpSetR)
#example input, 4 samples, 250 variants
set.seed(1); d <- data.frame(matrix(sample(c("0|0", "0|1", "0|1", "1|1"), 1000,
replace = TRUE), ncol = 4))
head(d)
# X1 X2 X3 X4
# 1 0|0 0|0 0|1 0|1
# 2 1|1 1|1 0|1 0|1
# 3 0|1 0|1 0|1 1|1
# 4 0|0 0|0 0|0 0|1
# 5 0|1 0|0 0|0 1|1
# 6 0|0 0|1 0|1 0|1
variants <- seq(nrow(d))
# subset variants that have "1|1", update as needed
dl <- lapply(d, function(i) variants[ grepl("1|1", i, fixed = TRUE) ])
# lengths(dl)
# X1 X2 X3 X4
# 57 66 66 61
upset(fromList(dl))
It worked, Thank you very much!
Log in to answer this question.