On Tue, Feb 16, 2010 at 10:26 AM, Ivan Gregoretti <ivangreg@gmail.com>wrote:

> Hi Everybody,
>
> How do you resize 'width' according to strandedness?
>
>
Something like:

ranges(rd) <- resize(ranges(rd), start = rd$stand == "+")


> For example, lets say I have
>
> A <- RangedData(IRanges(start=c(1001, 3501, 7001, 601, 2201),
>                        end=c(1500, 4000, 8500, 1300, 2300),
>                        names=c("gene1", "gene2", "gene3", "gene4",
> "gene5")),
>                space=c("chr1", "chr1", "chr1", "chr2", "chr2"),
>                strand=c("+", "-", "+", "-", "+"))
>
> > A
> RangedData with 5 rows and 1 value column across 2 spaces
>            space       ranges |      strand
>      <character>    <IRanges> | <character>
> gene1        chr1 [1001, 1500] |           +
> gene2        chr1 [3501, 4000] |           -
> gene3        chr1 [7001, 8500] |           +
> gene4        chr2 [ 601, 1300] |           -
> gene5        chr2 [2201, 2300] |           +
>
> Now I want to resize the widths to a single nucleotide starting at
> 'start' when the strand is '+' or starting at
> 'end' if the strand is '-'.
> The end product should be this:
>
> B <- RangedData(IRanges(start=c(1001, 4000, 7001, 1300, 2101),
>                        end=c(1001, 4000, 7001, 1300, 2201),
>                        names=c("gene1", "gene2", "gene3", "gene4",
> "gene5")),
>                space=c("chr1", "chr1", "chr1", "chr2", "chr2"),
>                strand=c("+", "-", "+", "-", "+"))
> > B
>
> RangedData with 5 rows and 1 value column across 2 spaces
>            space       ranges |      strand
>      <character>    <IRanges> | <character>
> gene1        chr1 [1001, 1001] |           +
> gene2        chr1 [4000, 4000] |           -
> gene3        chr1 [7001, 7001] |           +
> gene4        chr2 [1300, 1300] |           -
> gene5        chr2 [2101, 2201] |           +
>
> I wonder if there is a concise way of achieving this manipulation.
>
> For a wordy version, you can always count on me. :)
>
> Thank you,
>
> Ivan
>
> > sessionInfo()
> R version 2.10.0 (2009-10-26)
> x86_64-redhat-linux-gnu
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
> LC_TIME=en_US.UTF-8
>  [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=C
> LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
> LC_ADDRESS=C
> [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8
> LC_IDENTIFICATION=C
>
> attached base packages:
> [1] grid      splines   stats     graphics  grDevices utils
> datasets  methods
> [9] base
>
> other attached packages:
>  [1] org.Mm.eg.db_2.3.6                  ChIPpeakAnno_1.2.3
>  [3] org.Hs.eg.db_2.3.6                  GO.db_2.3.5
>  [5] RSQLite_0.8-2                       AnnotationDbi_1.8.1
>  [7] BSgenome.Ecoli.NCBI.20080805_1.3.16 BSgenome_1.14.2
>  [9] multtest_2.2.0                      Biobase_2.6.1
> [11] biomaRt_2.2.0                       RMySQL_0.7-4
> [13] DBI_0.2-5                           gplots_2.7.4
> [15] caTools_1.10                        gdata_2.7.1
> [17] gtools_2.6.1                        lattice_0.18-3
> [19] Hmisc_3.7-0                         survival_2.35-8
> [21] Biostrings_2.14.12                  IRanges_1.4.11
> [23] rtracklayer_1.6.0                   RCurl_1.3-1
> [25] bitops_1.0-4.1
>
> loaded via a namespace (and not attached):
> [1] cluster_1.12.1 MASS_7.3-3     tools_2.10.0   XML_2.6-0
>
>
> Ivan Gregoretti, PhD
> National Institute of Diabetes and Digestive and Kidney Diseases
> National Institutes of Health
> 5 Memorial Dr, Building 5, Room 205.
> Bethesda, MD 20892. USA.
> Phone: 1-301-496-1592
> Fax: 1-301-496-9878
>
> _______________________________________________
> Bioc-sig-sequencing mailing list
> Bioc-sig-sequencing@r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
>

	[[alternative HTML version deleted]]

