Change sign from Granges scores to visualize negative strand data
1
0
Entering edit mode
ferbecneu • 0
@ferbecneu-16188
Last seen 4.1 years ago

Hello I wish to add minus signs in my granges scores. These scores come from a Gro-seq bigwig and they are counts from the negative strand however they come as positive values. I want to make them negative so that I can visualize the signal together with positive strand tracks in the genome browser. Can this be done in granges? Thank you very much!

granges rtracklayer • 1.3k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 41 minutes ago
United States
> z <- GRanges(rep("chr1", 10), IRanges(1:10, 31:40))
> z
GRanges object with 10 ranges and 0 metadata columns:
       seqnames    ranges strand
          <Rle> <IRanges>  <Rle>
   [1]     chr1      1-31      *
   [2]     chr1      2-32      *
   [3]     chr1      3-33      *
   [4]     chr1      4-34      *
   [5]     chr1      5-35      *
   [6]     chr1      6-36      *
   [7]     chr1      7-37      *
   [8]     chr1      8-38      *
   [9]     chr1      9-39      *
  [10]     chr1     10-40      *
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
> strand(z) <- rep("-", 10)
> z
GRanges object with 10 ranges and 0 metadata columns:
       seqnames    ranges strand
          <Rle> <IRanges>  <Rle>
   [1]     chr1      1-31      -
   [2]     chr1      2-32      -
   [3]     chr1      3-33      -
   [4]     chr1      4-34      -
   [5]     chr1      5-35      -
   [6]     chr1      6-36      -
   [7]     chr1      7-37      -
   [8]     chr1      8-38      -
   [9]     chr1      9-39      -
  [10]     chr1     10-40      -
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
ADD COMMENT
0
Entering edit mode

Or maybe you mean something in the mcols slot?

> mcols(z)$scores <- runif(10)
> z
GRanges object with 10 ranges and 1 metadata column:
       seqnames    ranges strand |            scores
          <Rle> <IRanges>  <Rle> |         <numeric>
   [1]     chr1      1-31      - | 0.781348916934803
   [2]     chr1      2-32      - | 0.689271170645952
   [3]     chr1      3-33      - |  0.50072684045881
   [4]     chr1      4-34      - | 0.113180985907093
   [5]     chr1      5-35      - | 0.495131695410237
   [6]     chr1      6-36      - | 0.868058342020959
   [7]     chr1      7-37      - | 0.615485859103501
   [8]     chr1      8-38      - | 0.418453785357997
   [9]     chr1      9-39      - | 0.155853351112455
  [10]     chr1     10-40      - | 0.831564369145781
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
> mcols(z)$scores <- -1*mcols(z)$scores
> z
GRanges object with 10 ranges and 1 metadata column:
       seqnames    ranges strand |             scores
          <Rle> <IRanges>  <Rle> |          <numeric>
   [1]     chr1      1-31      - | -0.781348916934803
   [2]     chr1      2-32      - | -0.689271170645952
   [3]     chr1      3-33      - |  -0.50072684045881
   [4]     chr1      4-34      - | -0.113180985907093
   [5]     chr1      5-35      - | -0.495131695410237
   [6]     chr1      6-36      - | -0.868058342020959
   [7]     chr1      7-37      - | -0.615485859103501
   [8]     chr1      8-38      - | -0.418453785357997
   [9]     chr1      9-39      - | -0.155853351112455
  [10]     chr1     10-40      - | -0.831564369145781
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
> 
ADD REPLY
0
Entering edit mode

It was the second scenario. Thank you very much!

ADD REPLY
0
Entering edit mode

It was the second scenario. Thank you very much!

ADD REPLY

Login before adding your answer.

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