[R] single strip for the same group in dotplot lattice

Duncan Mackay dulcalma at bigpond.com
Thu Feb 23 06:31:38 CET 2017


Resending the previous email as the data = mdata2 is wrong for the first
plot should be mdata

dotplot(
  value ~ type|ct,
  mdata,
  groups = typeT,
  par.settings = list(strip.background = list(col="paleturquoise"),
                      superpose.symbol = list(col = c(2:4),
                                              pch = rep(c(1,20),each = 3))),
# type
  scales = list(alternating = FALSE, x = list(labels = c("", "", ""))),
  main = "Luminex analysis MTb humans",
  xlab = "Target", 
  ylab = "Reading",
  auto.key = T
)


Adding:
Depending on preferences for cluster (run) and target the new columns could
be changed to suit.

With "duplication" pch and col, rather than arguments themselves can be
adjusted to suit in par.settings which makes doing the key easier

Regards

Duncan


-----Original Message-----
From: Duncan Mackay [mailto:dulcalma at bigpond.com] 
Sent: Thursday, 23 February 2017 13:50
To: R; 'Luigi Marongiu'
Subject: RE: [R] single strip for the same group in dotplot lattice

Hi Liugi

Here are some ideas quickly

4 panels diagonals are blank

mdata = my.data
mdata$ct <- paste(target, "Run", rep(1:2, each = 6))
mdata$typeT <- paste(mdata$target,mdata$type)

dotplot(
  value ~ type|ct,
  mdata2,
  groups = typeT,
  par.settings = list(strip.background = list(col="paleturquoise"),
                      superpose.symbol = list(col = c(2:4),
                                              pch = rep(c(1,20),each = 3))),
# type
  scales = list(alternating = FALSE, x = list(labels = c("", "", ""))),
  main = "Luminex analysis MTb humans",
  xlab = "Target", 
  ylab = "Reading",
  auto.key = T,
  panel = panel.superpose
)

# for when the 4 panels have plots not 2 as now
 mdata2 = mdata
 mdata2$target = rep(LETTERS[2:1], ea=6)
 mdata2$value= mdata2$value+0.1
 mdata2 <- rbind(mdata,mdata2)

mdata2$typeT <- paste(mdata2$target,mdata2$type)

 dotplot(
   value ~ type|target + cluster,
   mdata2,
   groups = typeT,
   par.settings = list(strip.background = list(col="paleturquoise"),
                       superpose.symbol = list(col = c(2:4),
                                               pch = rep(c(1,20),each =
3))), # type
   scales = list(alternating = FALSE, x = list(labels = c("", "", ""))),
   main = "Luminex analysis MTb humans",
   xlab = "Target", 
   ylab = "Reading",
   auto.key = T,
   panel = panel.superpose
 )


 dotplot(
   value ~ type|ct,
   mdata2,
   groups = typeT,
   par.settings = list(strip.background = list(col="paleturquoise"),
                       superpose.symbol = list(col = c(2:4),
                                               pch = rep(c(1,20),each =
3))), # type
   scales = list(alternating = FALSE, x = list(labels = c("", "", ""))),
   main = "Luminex analysis MTb humans",
   strip    = strip.custom(factor.levels = paste("Run",1:2),
                        par.strip.text = list(cex = 1) ),
   xlab = "Target", 
   ylab = "Reading",
   auto.key = T,
   panel = panel.superpose
 )

dotplot(
  value ~ type|cluster,
  mdata2,
  groups = typeT,
  par.settings = list(strip.background = list(col="paleturquoise"),
                      superpose.symbol = list(col = c(2:4),
                                              pch = rep(c(1,20),each = 3))),
# type
  scales = list(alternating = FALSE, x = list(labels = c("", "", ""))),
  main = "Luminex analysis MTb humans",
  xlab = "Target", 
  ylab = "Reading",
  auto.key = T,
  panel = panel.superpose
)


Regards

Duncan

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Luigi
Marongiu
Sent: Wednesday, 22 February 2017 21:26
To: P Tennant; r-help
Subject: Re: [R] single strip for the same group in dotplot lattice

Dear Philip,
the data is indeed a toy data: the real one will have 15 panels (=targets)
and two or three clusters. this means that I will have 15 strips with the
label "run 1" = "cluster 1" etc. the point of the toy data is that I get a
4x4 panel plot with 8 strips labelled "run 1", "run 2", "A" and "B". What I
am looking for is to collapse the strips so to get only one label "run 1"
and only one with "run 2" in order to simplify the plot. Hope this helps.
Thanks
Luigi

On Wed, Feb 22, 2017 at 9:53 AM, P Tennant <philipt900 at iinet.net.au> wrote:

> Hi Luigi,
>
> I'm afraid I don't understand your toy data as you've described it, but if
> you really don't have run 2 for target A, and don't have run 1 for target
> B, why not just create another factor that reflects this, and plot that?
>
>  my.data$clus2 <- with(my.data, interaction(cluster, target))
>
>  and call: dotplot(value ~ type| clus2, ... )
>
>
> Philip
>
>
> On 22/02/2017 8:03 PM, Luigi Marongiu wrote:
>
>> dear all,
>> I have a set of data that is subdivided in cluster (run 1/run 2) and in
>> target (A/B). When plotting, I obtain a panel strip with "run 1" and "run
>> 2" for each "A" and "B" panel, so "run 1" appears twice and so does "run
>> 2". It is possible to merge the strip together so that I will have "run
1"
>> or "run 2" only once? this will reduce the complexity of the data and
>> allow
>> more space for more detailed information in the strip.
>> the data follows,
>> thank you
>> L
>>
>> cluster<- c(rep("run_1", 6), rep("run_2", 6))
>> type<- rep(c("blank", "positive", "negative"),2)
>> target<- c(rep("A", 6), rep("B", 6))
>> value<- c(0.01, 1.1, 0.5,
>>             0.02, 1.6, 0.8,
>>             0.07, 1.4, 0.7,
>>             0.03, 1.4, 0.4)
>> my.data<- data.frame(cluster, type, target, value)
>>
>> library(lattice)
>> dotplot(
>>    value ~ type|target + cluster,
>>    my.data,
>>    groups = type,
>>    pch=21,
>>    main = "Luminex analysis MTb humans",
>>    xlab = "Target", ylab = "Reading",
>>    col = c("grey", "green", "red"),
>>    par.settings = list(strip.background = list(col="paleturquoise")),
>>    scales = list(alternating = FALSE, x = list(labels = c("", "", ""))),
>>    key = list(
>>      space = "top",
>>      columns = 3,
>>      text = list(c("Blank", "Negative", "Positive"), col="black"),
>>      rectangles = list(col=c("grey", "green", "red"))
>>    )
>> )
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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