Elementwise appending of List elements?
1
0
Entering edit mode
@ryan-c-thompson-5618
Last seen 9 months ago
Scripps Research, La Jolla, CA
Hi all, I have 2 CharacterList objects (let's call them A and B) of equal length, and I want to append the each element of List A to the corresponding one in List B and get the resulting CharacterList. I can do this with mendoapply(c, A, B), but this is quite slow. Is there a function to do this quickly? -Ryan
• 582 views
ADD COMMENT
0
Entering edit mode
@herve-pages-1542
Last seen 3 days ago
Seattle, WA, United States
Hi Ryan, On 06/18/2014 11:33 AM, Ryan C. Thompson wrote: > Hi all, > > I have 2 CharacterList objects (let's call them A and B) of equal > length, and I want to append the each element of List A to the > corresponding one in List B and get the resulting CharacterList. I can > do this with mendoapply(c, A, B), but this is quite slow. Is there a > function to do this quickly? Code adapted from "junctions" method for GAlignmentPairs objects: library(GenomicAlignments) pcombine <- function(x, y) { stopifnot(length(x) == length(y)) xy <- c(x, y) collate_subscript <- S4Vectors:::make_XYZxyz_to_XxYyZz_subscript(length(x)) tmp <- xy[collate_subscript] GenomicAlignments:::shrinkByHalf(tmp) } I'll add something like this to S4Vectors. Cheers, H. > > -Ryan > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpages at fhcrc.org Phone: (206) 667-5791 Fax: (206) 667-1319
ADD COMMENT
0
Entering edit mode
Hi, Is this only for the devel version? There doesn't seem to be an S4Vectors package for R 3.1.0. -Ryan On Wed 18 Jun 2014 11:51:57 AM PDT, Hervé Pagès wrote: > Hi Ryan, > > On 06/18/2014 11:33 AM, Ryan C. Thompson wrote: >> Hi all, >> >> I have 2 CharacterList objects (let's call them A and B) of equal >> length, and I want to append the each element of List A to the >> corresponding one in List B and get the resulting CharacterList. I can >> do this with mendoapply(c, A, B), but this is quite slow. Is there a >> function to do this quickly? > > Code adapted from "junctions" method for GAlignmentPairs objects: > > library(GenomicAlignments) > > pcombine <- function(x, y) > { > stopifnot(length(x) == length(y)) > xy <- c(x, y) > collate_subscript <- > S4Vectors:::make_XYZxyz_to_XxYyZz_subscript(length(x)) > tmp <- xy[collate_subscript] > GenomicAlignments:::shrinkByHalf(tmp) > } > > I'll add something like this to S4Vectors. > > Cheers, > H. > >> >> -Ryan >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor at r-project.org >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: >> http://news.gmane.org/gmane.science.biology.informatics.conductor >
ADD REPLY
0
Entering edit mode
On 06/18/2014 03:38 PM, Ryan C. Thompson wrote: > Hi, > > Is this only for the devel version? There doesn't seem to be an > S4Vectors package for R 3.1.0. In BioC release (2.14), make_XYZxyz_to_XxYyZz_subscript() is in IRanges. Note that both BioC release (2.14) and devel (3.0) use R 3.1.0. The S4Vectors package is new in BioC devel. It's a split from the IRanges package so most of the stuff that is now in S4Vectors used to be in IRanges. H. > > -Ryan > > On Wed 18 Jun 2014 11:51:57 AM PDT, Hervé Pagès wrote: >> Hi Ryan, >> >> On 06/18/2014 11:33 AM, Ryan C. Thompson wrote: >>> Hi all, >>> >>> I have 2 CharacterList objects (let's call them A and B) of equal >>> length, and I want to append the each element of List A to the >>> corresponding one in List B and get the resulting CharacterList. I can >>> do this with mendoapply(c, A, B), but this is quite slow. Is there a >>> function to do this quickly? >> >> Code adapted from "junctions" method for GAlignmentPairs objects: >> >> library(GenomicAlignments) >> >> pcombine <- function(x, y) >> { >> stopifnot(length(x) == length(y)) >> xy <- c(x, y) >> collate_subscript <- >> S4Vectors:::make_XYZxyz_to_XxYyZz_subscript(length(x)) >> tmp <- xy[collate_subscript] >> GenomicAlignments:::shrinkByHalf(tmp) >> } >> >> I'll add something like this to S4Vectors. >> >> Cheers, >> H. >> >>> >>> -Ryan >>> >>> _______________________________________________ >>> Bioconductor mailing list >>> Bioconductor at r-project.org >>> https://stat.ethz.ch/mailman/listinfo/bioconductor >>> Search the archives: >>> http://news.gmane.org/gmane.science.biology.informatics.conductor >> -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpages at fhcrc.org Phone: (206) 667-5791 Fax: (206) 667-1319
ADD REPLY

Login before adding your answer.

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