[R] to represent color range on plot segment

Dennis Murphy djmuser at gmail.com
Sat Aug 27 21:34:10 CEST 2011


On Sat, Aug 27, 2011 at 11:07 AM, karthicklakshman
<karthick.lakshman at gmail.com> wrote:
> Dear R community,
>
> With an advantage of being "NEW" to R, I would like to post a very basic
> query here,

Really? I found two posts with your name on it dating from October and
November of 2010.
http://r-project.markmail.org/search/?q=karthicklakshman

>
> I am in need of representing gene expression data which ranges from -0.09 to
> +4, on plot "segment". please find below the data df, the expression values
> are in df[,2]. kindly help me with the code, so that I can represent the
> values with a clear color gradient (something like -0.09 to 0 as red
> gradient and 0 to +4 as green gradient)

Please read the posting guide, linked at the bottom of this mail,
especially the part about 'reproducible example'. You provided the
data, but no code to show that you made a serious effort to solve this
problem on your own. Moreover, since this is related to gene
expression data, the Bioconductor list may be more appropriate for
future questions re gene expression:
http://www.bioconductor.org/help/mailing-list/

although this one is within the purview of R-help IMO. Use the sign of
value (?sign) as an indicator variable to which you can map colors.
I'd also think about creating a value for location (midpoint, maybe?)
to simplify the plot call. It shouldn't be too difficult to do this in
any of base graphics, lattice or ggplot2.

Dennis
>
>            location         value
> 15  chr+:14001-15001  0.99749499
> 16  chr+:15001-16001  0.99957360
> 17  chr+:16001-17001  0.99166481
> 18  chr+:17001-18001  0.97384763
> 19  chr+:18001-19001  0.94630009
> 20  chr+:19001-20001  0.90929743
> 21  chr+:20001-21001  0.86320937
> 22  chr+:21001-22001  0.80849640
> 23  chr+:22001-23001  0.74570521
> 24  chr+:23001-24001  0.67546318
> 25  chr+:24001-25001  0.59847214
> 26  chr+:25001-26001  0.51550137
> 27  chr+:26001-27001  0.42737988
> 28  chr+:27001-28001  0.33498815
> 29  chr+:28001-29001  0.23924933
> 30  chr+:29001-30001  0.14112001
> 31  chr+:30001-31001  0.04158066
> 32  chr+:31001-32001 -0.05837414
> 33  chr+:32001-33001 -0.15774569
> 34  chr+:33001-34001 -0.25554110
> 35  chr+:34001-35001 -0.35078323
> 36  chr+:35001-36001 -0.44252044
> 37  chr+:36001-37001 -0.52983614
> 38  chr+:37001-38001 -0.61185789
> 39  chr+:38001-39001 -0.68776616
> 40  chr+:39001-40001 -0.75680250
> 41  chr+:40001-41001 -0.81827711
> 42  chr+:41001-42001 -0.87157577
> 43  chr+:42001-43001 -0.91616594
> 44  chr+:43001-44001 -0.95160207
>
> Thanks in advance,
> regards,
> karthick
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/to-represent-color-range-on-plot-segment-tp3773392p3773392.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list