Plot multiple bed files using R package Gviz
1
0
Entering edit mode
3.9 years ago
genie66 ▴ 30

Hi, I am new to R and looking for some help in plotting multiple bed files which may or may not overlap. They do have multiple chromosomes. I found a package called Gviz, where a Chromosome ideogram and genomic region could be plotted. But I am not sure how to load a bed file.

I am aiming to plot plain bed files(chr ,start,stop) to see which regions are overlapping in multiple bed files I have.

From below example code I see they loaded two data sets called cpgislands and genemodel (believe that comes with package), like wise is there a way to load my bed files to plot them?

data(**cpgIslands**) 
atr <- AnnotationTrack(**cpgIslands**, name="CpG")

gtr <- GenomeAxisTrack()
itr <- IdeogramTrack(genome="mm9", chromosome="chr1")

data(**geneModels**)
grtr <- GeneRegionTrack(**geneModels**, name="Gene Model", showId=TRUE)

plotTracks(list(itr, gtr, atr, grtr))

Please help me with this. Thanks.

R Gvi .bed bed plot • 4.0k views
ADD COMMENT
2
Entering edit mode
3.9 years ago
goodez ▴ 540
library(Gviz)
library(rtracklayer)

sample1 <- import.bed('your_file1.bed')
sample2 <- import.bed('your_file2.bed')

track1 <- DataTrack(sample1, . . .)
track2 <- DataTrack(sample2, . . .)

plotTracks(track1, track2, . . .)

ADD COMMENT
1
Entering edit mode

Hi, thanks for you response. I couldn't do import.bed but sample1 <- read.table("custom.bed",header = TRUE, sep="\t",stringsAsFactors=FALSE, quote="") worked, but the DataTrack function shows the following error, Error in .fillWithDefaults(range, defaults[missing], args[missing], len = nrow(range)) : The mandatory argument 'NA' is missing with no default. I do not have ranges or other values for each regions. I am aiming to plot plain bed files(chr ,start,stop) to see which regions are overlapping in the multiple bed files I have. Appreciate any help.

ADD REPLY
0
Entering edit mode

What happens when you just try running library(rtrackalyer)? Can you show the output? The rtracklayer package should include the import.bed function, which will allow you to make the correct object with ranges.

ADD REPLY

Login before adding your answer.

Traffic: 1343 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6