Question: Plot multiple bed files using R package Gviz
0
gravatar for genie66
13 months ago by
genie6620
United States
genie6620 wrote:

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.

plot bed gvi .bed R • 1.1k views
ADD COMMENTlink modified 12 months ago • written 13 months ago by genie6620
2
gravatar for goodez
13 months ago by
goodez460
United States
goodez460 wrote:
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 COMMENTlink written 13 months ago by goodez460

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 REPLYlink written 12 months ago by genie6620

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 REPLYlink written 12 months ago by goodez460
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 566 users visited in the last hour