Entering edit mode
10 weeks ago
adarsh_munna
▴
50
Hi,
I am trying to create an SNP Density plot from VCF file using a custom genome file. However when I am plotting the graph, I am getting a colourless plot which does not look good. Can anyone please let me how can I customise this plot so that I can visualize the data in a better way?
Here is my code:
suppressPackageStartupMessages(library(karyoploteR))
library(vcfR)
# Read the VCF file
vcf <- read.vcfR("inputvcf")
# Extracting the SNP data
snp_data <- as.data.frame(getFIX(vcf)[, c("CHROM", "POS")])
snp_data$END <- snp_data$POS # Set END position equal to POS for SNPs
# Convert to GRanges object
gr <- toGRanges(snp_data)
# Plot the SNP density
# Initialize the karyotype plot for the desired genome
custom.genome <- toGRanges(data.frame(chr=c("1", "2","3","4","5","6","7","8","9","10","11","12"), start=c(1,1,1,1,1,1,1,1,1,1,1,1), end=c(39866532, 33962743,34446443,30521686,26652778,27870862,26200591,25958679,20482102,20731201,27785585,23561512)))
kp <- plotKaryotype(genome = custom.genome) # Change to your genome build
# Plot SNP density
kpPlotDensity(kp, data = gr, window.size = 10000)
I am getting the following plot:
Also, I would like to know if there is any packages are available to get a plot similar to the following image made by SRplot online tool?
I think it is from CMplot package: