Re: [R] still a problem remainingRE: Data lebals xylattice plot: RE: displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function

From: Umesh Rosyara <rosyaraur_at_gmail.com>
Date: Thu, 10 Mar 2011 19:06:12 -0500

Thank you so much for the advice. The R could not find function "intersection". Do I need additional package to have this function active. I tried "intersect" instead has no effect.  

xyplot(p ~ xvar|chr, data=dataf,
panel=function(x, y, subscripts){
panel.xyplot(x, y)
ok= intersection(subscripts, which(dataf$p < 0.05)) with(dataf[ok,], panel.text(p, xvar, name))  }, as.table=T, subscripts=T)    

Best Regards  

Umesh R        


From: foolish.android_at_gmail.com [mailto:foolish.android_at_gmail.com] On Behalf Of Felix Andrews
Sent: Thursday, March 10, 2011 7:01 AM
To: Umesh Rosyara
Cc: R mailing list; Deepayan.Sarkar_at_r-project.org
Subject: Re: [R] still a problem remainingRE: Data lebals xylattice plot: RE: displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function

Notice that pvals is a subset of dataf so 'subscripts' can not be applied directly to pvals. Instead you should do the subsetting inside the panel function. e.g.
ok <- intersection(subscripts, which(dataf$p < 0.05)) with(dataf[ok,], panel.text(p, xval, name))

By the way you should include the dots (...) in your panel function arguments and pass them on to panel.xyplot.

On Thursday, 10 March 2011, Umesh Rosyara <rosyaraur_at_gmail.com> wrote:
> Lattice-experts:
> Thank you for those who have responded earlier. I have not got a perfect
> solution yet but tried several ways, unless anybody really lattice killer
> steps up, I will leave it and see alternatives. Sorry to send it again.
>
>
>
> #Data
>
> name <- c(paste ("M", 1:1000, sep = ""))
> xvar <- seq(1, 10000, 10)
> chr <- c(rep(1,200),rep(2,200), rep(3,200), rep(4,200), rep(5,200))
> set.seed(134)
> p <- rnorm(1000, 0.15,0.05)
> dataf <- data.frame(name,xvar, chr, p)
> dataf$chr <- as.factor(dataf$chr)
>
>
>
> #subset data
>
> pvals <- dataf[dataf$p < 0.05,]
>
>
>
> # unsuccessful commands
>
> xyplot(p ~ xvar|chr, data=dataf,
> panel=function(x, y, subscripts){
>
> panel.xyplot(x, y)
>
> panel.xyplot(pvals$xvar[subscripts],pvals$p[subscripts], pch=6)
> panel.abline(h=0.01, col="red")
>
>
> panel.text(pvals$xvar[subscripts], pvals$p[subscripts],
> pvals$name[subscripts], col="green2")
>
>
> }, as.table=T, subscripts=T)
>
>
>
>
>
> Best Regards
>
> Umesh R
>
>
>
>
> _____
>
> From: Bert Gunter [mailto:gunter.berton_at_gene.com]
> Sent: Tuesday, March 08, 2011 12:00 AM
> To: Umesh Rosyara
> Cc: Jorge Ivan Velez; Dennis Murphy; sarah.goslee_at_gmail.com; R mailing
list
> Subject: Re: still a problem remainingRE: [R] Data lebals xylattice plot:
> RE: displaying label meeting condition (i.e. significant, i..e p value
less
> than 005) in plot function
>
>
>
> As I believe I already told you in my original reply, you have to make
> use of the subscripts argument in the panel function to subscript the
> P values etc. vector to be plotted in each panel. Something like:
> (untested)
>
> panel = function(x, y,subscripts,...) {
> panel.xyplot(x, y,...)
> panel.abline(h=0.01, col="red")
> panel.text(xv1[subscripts], p1[subscripts],
> n1[subscripts], col="green2")
> }
>
>
> Also,in future, please send plain text email, as requested in the
> guide. Your message was in an annoying blue font in my gmail reader.
>
> Cheers,
> Bert
>
>
> On Mon, Mar 7, 2011 at 5:26 PM, Umesh Rosyara <rosyaraur_at_gmail.com> wrote:
>> Hi Lattice Users
>>
>> I have been working to fix this problem, still I am not able to solve
> fully.
>> I could label those names that have pvalue less than 0.01 but still the
>> label appears in all compoent plots eventhough those who do have the
> pvalue
>> ! How can I implement it successuflly to grouped data like mine. You help

> is
>> highly appreciated.
>>
>> #my data
>> name <- c(paste ("M", 1:1000, sep = ""))
>> xvar <- seq(1, 10000, 10)
>> chr <- c(rep(1,200),rep(2,200), rep(3,200), rep(4,200), rep(5,200))
>> set.seed(134)
>> p <- rnorm(1000, 0.15,0.05)
>> dataf <- data.frame(name,xvar, chr, p)
>> dataf$chr <- as.factor(dataf$chr)
>>
>> # lattice plot: As far as I can go now ! little progress but final push
>> required !
>> require(lattice)
>> pvals <- dataf[dataf$p < 0.01,]
>> p1 <- pvals$p
>> n1 <- pvals$name
>> xv1 <- pvals$xvar
>> xyplot(p ~ xvar|chr, data=dataf,
>> panel = function(x, y) {
>> panel.xyplot(x, y)
>> panel.abline(h=0.01, col="red")
>> panel.text(xv1, p1, n1, col="green2")
>> })
>>
>> Thank you in advance.
>>
>> Best Regards
>>
>> Umesh R
>>
>>
>>
>> ________________________________
>> From: Bert Gunter [mailto:gunter.berton_at_gene.com]
>> Sent: Sunday, March 06, 2011 10:50 AM
>> To: Umesh Rosyara
>> Cc: Jorge Ivan Velez; Dennis Murphy; sarah.goslee_at_gmail.com; R mailing
> list
>> Subject: Re: [R] Data lebals xylattice plot: RE: displaying label meeting

>> condition (i.e. significant, i..e p value less than 005) in plot function
>>
>> This is easy to do by specifying xyplot's panel function. Assuming
>> only one panel -- otherwise you need to pass the subscripts arguments
>> to choose the values belonging to the panel -- somethings like:
>>
>> xyplot(y~x, pvals = pvals,..., ## pvals is your vector of small p
>> values with e.g. NA's elsewhere
>> panel = function(x,y, pvals,...) {
>> panel.xyplot(...)
>> panel.text((x,y, pvals,...)
>> } )
>>
>> This is obviously just a sketch and will not work as written. So
>> please read the Help page on xyplot carefully and perhaps also
>> Deepayan's book on trellis graphics -- there are also undoubtedly
>> online resources: search on "trellis graphics tutorial" or some such.
>> This is not hard, but there are some details that you will need to
>> master,especially regarding argument passing.
>>
>> Another alternative is to use the layer() function in the latticeExtra
>> package instead. Consult the documentation there for details.
>>
>> Cheers,
>> Bert
>>
>>
>>
>> On Sun, Mar 6, 2011 at 5:17 AM, Umesh Rosyara <rosyaraur_at_gmail.com>
wrote:

>>> Dear Jorge, Dennis, Sarah and R-experts.
>>>
>>> Thank for helping me. As you mentioned it is difficult apply in lattice
>>> in
>>> this situation.
>>>
>>> Unless, there i

--
Felix Andrews / 安福立
http://www.neurofractal.org/felix/ 

  _____  

No virus found in this message.
Checked by AVG - www.avg.com



	[[alternative HTML version deleted]]

______________________________________________
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.
Received on Fri 11 Mar 2011 - 03:37:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Mar 2011 - 09:20:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive