Generate a GRangesList from a classical list of GRangesObjects
1
0
Entering edit mode
@hermann-norpois-5726
Last seen 9.7 years ago
Germany
Hello, I would like to generate a GRangesList object from multiple narrow peak files. I tried this and it works: ord <- function (ddir, namen){ #ddir is the directory of interest and namen a vector with names e.g. "GSM1008569" "GSM1008578" "GSM1008583" open.list <- sapply (namen, function (x) {feile <- list.files (ddir, pattern=x, full.names=TRUE) feile <- read.table (feile) file.gr <- GRanges (seqnames=feile$V1, ranges= IRanges (start=feile$V2, end=feile$V3), edensity=feile$V5, epeak=feile$V10) } ) names(open.list) <- namen return (open.list) } After for instance test <- ord (ddir, namen) I get a nice list of GRange objects but I would like to transform this in a GRangesList. How does it work? If there is an alternative approach to generate a GRangeList directly ( I guess there is one but I did not find a way to manage this) please let me know. Thanks Hermann [[alternative HTML version deleted]]
IRanges IRanges • 3.7k views
ADD COMMENT
0
Entering edit mode
Tim Triche ★ 4.2k
@tim-triche-3561
Last seen 4.3 years ago
United States
library(GenomicRanges) blah <- list(foo=GRanges(), bar=GRanges(), baz=GRanges()) class(blah) ## [1] "list" bleh <- GRangesList(blah) class(bleh) ## [1] "GRangesList" ## attr(,"package") ## [1] "GenomicRanges" In other words, I think you're looking for the GRangesList() function. On Wed, Feb 20, 2013 at 12:33 PM, Hermann Norpois <hnorpois@gmail.com>wrote: > Hello, > > I would like to generate a GRangesList object from multiple narrow peak > files. I tried this and it works: > > ord <- function (ddir, namen){ #ddir is the directory of interest and namen > a vector with names e.g. "GSM1008569" "GSM1008578" "GSM1008583" > > > open.list <- sapply (namen, function (x) {feile <- list.files (ddir, > pattern=x, full.names=TRUE) > feile <- read.table (feile) > file.gr <- GRanges (seqnames=feile$V1, > ranges= IRanges (start=feile$V2, end=feile$V3), edensity=feile$V5, > epeak=feile$V10) > > } > > ) > names(open.list) <- namen > return (open.list) > } > > After for instance > > test <- ord (ddir, namen) > > I get a nice list of GRange objects but I would like to transform this in a > GRangesList. How does it work? > If there is an alternative approach to generate a GRangeList directly ( I > guess there is one but I did not find a way to manage this) please let me > know. > > Thanks > Hermann > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor@r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > -- *A model is a lie that helps you see the truth.* * * Howard Skipper<http: cancerres.aacrjournals.org="" content="" 31="" 9="" 1173.full.pdf=""> [[alternative HTML version deleted]]
ADD COMMENT
0
Entering edit mode
So it was that simple ... It is. Thanks. 2013/2/21 Tim Triche, Jr. <tim.triche@gmail.com> > library(GenomicRanges) > > blah <- list(foo=GRanges(), bar=GRanges(), baz=GRanges()) > class(blah) > ## [1] "list" > > bleh <- GRangesList(blah) > class(bleh) > ## [1] "GRangesList" > ## attr(,"package") > ## [1] "GenomicRanges" > > In other words, I think you're looking for the GRangesList() function. > > > > > On Wed, Feb 20, 2013 at 12:33 PM, Hermann Norpois <hnorpois@gmail.com>wrote: > >> Hello, >> >> I would like to generate a GRangesList object from multiple narrow peak >> files. I tried this and it works: >> >> ord <- function (ddir, namen){ #ddir is the directory of interest and >> namen >> a vector with names e.g. "GSM1008569" "GSM1008578" "GSM1008583" >> >> >> open.list <- sapply (namen, function (x) {feile <- list.files (ddir, >> pattern=x, full.names=TRUE) >> feile <- read.table (feile) >> file.gr <- GRanges (seqnames=feile$V1, >> ranges= IRanges (start=feile$V2, end=feile$V3), edensity=feile$V5, >> epeak=feile$V10) >> >> } >> >> ) >> names(open.list) <- namen >> return (open.list) >> } >> >> After for instance >> >> test <- ord (ddir, namen) >> >> I get a nice list of GRange objects but I would like to transform this in >> a >> GRangesList. How does it work? >> If there is an alternative approach to generate a GRangeList directly ( I >> guess there is one but I did not find a way to manage this) please let me >> know. >> >> Thanks >> Hermann >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor@r-project.org >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: >> http://news.gmane.org/gmane.science.biology.informatics.conductor >> > > > > -- > *A model is a lie that helps you see the truth.* > * > * > Howard Skipper<http: cancerres.aacrjournals.org="" content="" 31="" 9="" 1173.full.pdf=""> > [[alternative HTML version deleted]]
ADD REPLY

Login before adding your answer.

Traffic: 740 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