# package plotrix: how to account for two two z categories

8 messages
Open this post in threaded view
|

## package plotrix: how to account for two two z categories

 Hello, I have an experiment measuring optical density (OD) when comparing three parameters: a) concentration of the target b) concentration of the probe c) concentration of the reporter antibody. Using plotrix I can nicely draw the first two into clusters, but I can't get separation for the third parameter. is there a way in plotrix to custer data according to two, let's say, z parameters (I call the second high-level parameter as w)? For instance, two clusters, each separated into two subclusters. Or is this more a job for lattice? Thank you. ``` x = rep(c(rep("1000 pmol", 4), rep("0 pmol", 4)),2) z =  rep(c(rep("Treated", 2), rep("Untreated", 2), rep("Treated", 2), rep("Untreated", 2))) w = c(rep("1:1000", 8), rep("1:2000", 8)) y = c(1.18, 1.22, 1.52, 2.37, 0.97, 1.08, 1.17, 1.58, 1.16, 1.16, 2.27, 2.24,       1.26, 1.28, 1.39, 1.77) Q = data.frame(x, z, w, y, stringsAsFactors = FALSE) names(Q) = c("[Target]", "Enzyme", "[Antibody]", "OD") names(Q) = c("x", "z", "w", "y") # for ease, I'll use single letters library(plotrix) brkdn.plot(y~x+z, data=Q,            pch = c(1, 16), cex = 1.5, type="p",            main="Single Measurement",            xlab=expression(bold("S1 nuclease")),            ylab=expression(bold("Optical density"))) brkdn.plot(y~x+z+w, data=Q,            pch = c(1, 16), cex = 1.5, type="p",            main="Double Measurement",            xlab=expression(bold("S1 nuclease")),            ylab=expression(bold("Optical density"))) ``` ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: package plotrix: how to account for two two z categories

 Hi Luigi, To display a nested breakdown like this I would suggest barNest. This is one way to display the nesting. Note that if you change the order of the factors in the formula you will get a different plot, so think about how you want the summaries nested. Error bars can only be displayed on the final breakdown. # because you have fairly long labels, use a wide plot x11(width=10) barcol<-list("lightgray",c("#ff00ff","#ff99ff"),  c("#00ff00","#66ff66"),c("#aaaa00","#888800")) barNest(y~x+z+w,Q,main="Double Measurement",  ylab="Response",col=barcol,errbars=TRUE) Jim On Wed, Sep 23, 2020 at 10:48 PM Luigi Marongiu <[hidden email]> wrote: > > Hello, > I have an experiment measuring optical density (OD) when comparing > three parameters: > a) concentration of the target > b) concentration of the probe > c) concentration of the reporter antibody. > Using plotrix I can nicely draw the first two into clusters, but I > can't get separation for the third parameter. is there a way in > plotrix to custer data according to two, let's say, z parameters (I > call the second high-level parameter as w)? For instance, two > clusters, each separated into two subclusters. Or is this more a job > for lattice? > Thank you. > > ``` > x = rep(c(rep("1000 pmol", 4), rep("0 pmol", 4)),2) > z =  rep(c(rep("Treated", 2), rep("Untreated", 2), rep("Treated", 2), > rep("Untreated", 2))) > w = c(rep("1:1000", 8), rep("1:2000", 8)) > y = c(1.18, 1.22, 1.52, 2.37, 0.97, 1.08, 1.17, 1.58, 1.16, 1.16, 2.27, 2.24, >       1.26, 1.28, 1.39, 1.77) > Q = data.frame(x, z, w, y, stringsAsFactors = FALSE) > names(Q) = c("[Target]", "Enzyme", "[Antibody]", "OD") > names(Q) = c("x", "z", "w", "y") # for ease, I'll use single letters > library(plotrix) > brkdn.plot(y~x+z, data=Q, >            pch = c(1, 16), cex = 1.5, type="p", >            main="Single Measurement", >            xlab=expression(bold("S1 nuclease")), >            ylab=expression(bold("Optical density"))) > brkdn.plot(y~x+z+w, data=Q, >            pch = c(1, 16), cex = 1.5, type="p", >            main="Double Measurement", >            xlab=expression(bold("S1 nuclease")), >            ylab=expression(bold("Optical density"))) > ``` > > ______________________________________________ > [hidden email] 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. ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: package plotrix: how to account for two two z categories

 Hi Luigi, I thought a lot about that when I was writing the function. The only way I could think of to show the nesting was dots with horizontal lines and it looked messy and was quite hard to visualize the nesting. If you do have any great ideas I always welcome contributions to plotrix. Jim On Thu, Sep 24, 2020 at 6:25 PM Luigi Marongiu <[hidden email]> wrote: > > Thank you Jim, that is really nice! > But is there a way to use dots instead of boxes? and how do I control > the colours? > Best regards > Luigi > > On Thu, Sep 24, 2020 at 9:29 AM Jim Lemon <[hidden email]> wrote: > > > > Hi Luigi, > > To display a nested breakdown like this I would suggest barNest. This > > is one way to display the nesting. Note that if you change the order > > of the factors in the formula you will get a different plot, so think > > about how you want the summaries nested. Error bars can only be > > displayed on the final breakdown. > > > > # because you have fairly long labels, use a wide plot > > x11(width=10) > > barcol<-list("lightgray",c("#ff00ff","#ff99ff"), > >  c("#00ff00","#66ff66"),c("#aaaa00","#888800")) > > barNest(y~x+z+w,Q,main="Double Measurement", > >  ylab="Response",col=barcol,errbars=TRUE) > > > > Jim > > > > On Wed, Sep 23, 2020 at 10:48 PM Luigi Marongiu > > <[hidden email]> wrote: > > > > > > Hello, > > > I have an experiment measuring optical density (OD) when comparing > > > three parameters: > > > a) concentration of the target > > > b) concentration of the probe > > > c) concentration of the reporter antibody. > > > Using plotrix I can nicely draw the first two into clusters, but I > > > can't get separation for the third parameter. is there a way in > > > plotrix to custer data according to two, let's say, z parameters (I > > > call the second high-level parameter as w)? For instance, two > > > clusters, each separated into two subclusters. Or is this more a job > > > for lattice? > > > Thank you. > > > > > > ``` > > > x = rep(c(rep("1000 pmol", 4), rep("0 pmol", 4)),2) > > > z =  rep(c(rep("Treated", 2), rep("Untreated", 2), rep("Treated", 2), > > > rep("Untreated", 2))) > > > w = c(rep("1:1000", 8), rep("1:2000", 8)) > > > y = c(1.18, 1.22, 1.52, 2.37, 0.97, 1.08, 1.17, 1.58, 1.16, 1.16, 2.27, 2.24, > > >       1.26, 1.28, 1.39, 1.77) > > > Q = data.frame(x, z, w, y, stringsAsFactors = FALSE) > > > names(Q) = c("[Target]", "Enzyme", "[Antibody]", "OD") > > > names(Q) = c("x", "z", "w", "y") # for ease, I'll use single letters > > > library(plotrix) > > > brkdn.plot(y~x+z, data=Q, > > >            pch = c(1, 16), cex = 1.5, type="p", > > >            main="Single Measurement", > > >            xlab=expression(bold("S1 nuclease")), > > >            ylab=expression(bold("Optical density"))) > > > brkdn.plot(y~x+z+w, data=Q, > > >            pch = c(1, 16), cex = 1.5, type="p", > > >            main="Double Measurement", > > >            xlab=expression(bold("S1 nuclease")), > > >            ylab=expression(bold("Optical density"))) > > > ``` > > > > > > ______________________________________________ > > > [hidden email] 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. > > > > -- > Best regards, > Luigi ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: package plotrix: how to account for two two z categories

 Oh, sorry, forgot about the colors. A list beginning with the color for the overall summary, then colors for the first factor and so on. See the help page for examples. Jim On Thu, Sep 24, 2020 at 6:32 PM Jim Lemon <[hidden email]> wrote: > > Hi Luigi, > I thought a lot about that when I was writing the function. The only > way I could think of to show the nesting was dots with horizontal > lines and it looked messy and was quite hard to visualize the nesting. > If you do have any great ideas I always welcome contributions to > plotrix. > > Jim > > On Thu, Sep 24, 2020 at 6:25 PM Luigi Marongiu <[hidden email]> wrote: > > > > Thank you Jim, that is really nice! > > But is there a way to use dots instead of boxes? and how do I control > > the colours? > > Best regards > > Luigi > > > > On Thu, Sep 24, 2020 at 9:29 AM Jim Lemon <[hidden email]> wrote: > > > > > > Hi Luigi, > > > To display a nested breakdown like this I would suggest barNest. This > > > is one way to display the nesting. Note that if you change the order > > > of the factors in the formula you will get a different plot, so think > > > about how you want the summaries nested. Error bars can only be > > > displayed on the final breakdown. > > > > > > # because you have fairly long labels, use a wide plot > > > x11(width=10) > > > barcol<-list("lightgray",c("#ff00ff","#ff99ff"), > > >  c("#00ff00","#66ff66"),c("#aaaa00","#888800")) > > > barNest(y~x+z+w,Q,main="Double Measurement", > > >  ylab="Response",col=barcol,errbars=TRUE) > > > > > > Jim > > > > > > On Wed, Sep 23, 2020 at 10:48 PM Luigi Marongiu > > > <[hidden email]> wrote: > > > > > > > > Hello, > > > > I have an experiment measuring optical density (OD) when comparing > > > > three parameters: > > > > a) concentration of the target > > > > b) concentration of the probe > > > > c) concentration of the reporter antibody. > > > > Using plotrix I can nicely draw the first two into clusters, but I > > > > can't get separation for the third parameter. is there a way in > > > > plotrix to custer data according to two, let's say, z parameters (I > > > > call the second high-level parameter as w)? For instance, two > > > > clusters, each separated into two subclusters. Or is this more a job > > > > for lattice? > > > > Thank you. > > > > > > > > ``` > > > > x = rep(c(rep("1000 pmol", 4), rep("0 pmol", 4)),2) > > > > z =  rep(c(rep("Treated", 2), rep("Untreated", 2), rep("Treated", 2), > > > > rep("Untreated", 2))) > > > > w = c(rep("1:1000", 8), rep("1:2000", 8)) > > > > y = c(1.18, 1.22, 1.52, 2.37, 0.97, 1.08, 1.17, 1.58, 1.16, 1.16, 2.27, 2.24, > > > >       1.26, 1.28, 1.39, 1.77) > > > > Q = data.frame(x, z, w, y, stringsAsFactors = FALSE) > > > > names(Q) = c("[Target]", "Enzyme", "[Antibody]", "OD") > > > > names(Q) = c("x", "z", "w", "y") # for ease, I'll use single letters > > > > library(plotrix) > > > > brkdn.plot(y~x+z, data=Q, > > > >            pch = c(1, 16), cex = 1.5, type="p", > > > >            main="Single Measurement", > > > >            xlab=expression(bold("S1 nuclease")), > > > >            ylab=expression(bold("Optical density"))) > > > > brkdn.plot(y~x+z+w, data=Q, > > > >            pch = c(1, 16), cex = 1.5, type="p", > > > >            main="Double Measurement", > > > >            xlab=expression(bold("S1 nuclease")), > > > >            ylab=expression(bold("Optical density"))) > > > > ``` > > > > > > > > ______________________________________________ > > > > [hidden email] 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. > > > > > > > > -- > > Best regards, > > Luigi ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: package plotrix: how to account for two two z categories

 Hi Luigi, Here is a quick example of how points would look in the same configuration. Perhaps with end caps to show the nesting it may be more like what you want. Jim On Thu, Sep 24, 2020 at 6:34 PM Jim Lemon <[hidden email]> wrote: > > Oh, sorry, forgot about the colors. A list beginning with the color > for the overall summary, then colors for the first factor and so on. > See the help page for examples. > > Jim > > On Thu, Sep 24, 2020 at 6:32 PM Jim Lemon <[hidden email]> wrote: > > > > Hi Luigi, > > I thought a lot about that when I was writing the function. The only > > way I could think of to show the nesting was dots with horizontal > > lines and it looked messy and was quite hard to visualize the nesting. > > If you do have any great ideas I always welcome contributions to > > plotrix. > > > > Jim > > > > On Thu, Sep 24, 2020 at 6:25 PM Luigi Marongiu <[hidden email]> wrote: > > > > > > Thank you Jim, that is really nice! > > > But is there a way to use dots instead of boxes? and how do I control > > > the colours? > > > Best regards > > > Luigi > > > > > > On Thu, Sep 24, 2020 at 9:29 AM Jim Lemon <[hidden email]> wrote: > > > > > > > > Hi Luigi, > > > > To display a nested breakdown like this I would suggest barNest. This > > > > is one way to display the nesting. Note that if you change the order > > > > of the factors in the formula you will get a different plot, so think > > > > about how you want the summaries nested. Error bars can only be > > > > displayed on the final breakdown. > > > > > > > > # because you have fairly long labels, use a wide plot > > > > x11(width=10) > > > > barcol<-list("lightgray",c("#ff00ff","#ff99ff"), > > > >  c("#00ff00","#66ff66"),c("#aaaa00","#888800")) > > > > barNest(y~x+z+w,Q,main="Double Measurement", > > > >  ylab="Response",col=barcol,errbars=TRUE) > > > > > > > > Jim > > > > > > > > On Wed, Sep 23, 2020 at 10:48 PM Luigi Marongiu > > > > <[hidden email]> wrote: > > > > > > > > > > Hello, > > > > > I have an experiment measuring optical density (OD) when comparing > > > > > three parameters: > > > > > a) concentration of the target > > > > > b) concentration of the probe > > > > > c) concentration of the reporter antibody. > > > > > Using plotrix I can nicely draw the first two into clusters, but I > > > > > can't get separation for the third parameter. is there a way in > > > > > plotrix to custer data according to two, let's say, z parameters (I > > > > > call the second high-level parameter as w)? For instance, two > > > > > clusters, each separated into two subclusters. Or is this more a job > > > > > for lattice? > > > > > Thank you. > > > > > > > > > > ``` > > > > > x = rep(c(rep("1000 pmol", 4), rep("0 pmol", 4)),2) > > > > > z =  rep(c(rep("Treated", 2), rep("Untreated", 2), rep("Treated", 2), > > > > > rep("Untreated", 2))) > > > > > w = c(rep("1:1000", 8), rep("1:2000", 8)) > > > > > y = c(1.18, 1.22, 1.52, 2.37, 0.97, 1.08, 1.17, 1.58, 1.16, 1.16, 2.27, 2.24, > > > > >       1.26, 1.28, 1.39, 1.77) > > > > > Q = data.frame(x, z, w, y, stringsAsFactors = FALSE) > > > > > names(Q) = c("[Target]", "Enzyme", "[Antibody]", "OD") > > > > > names(Q) = c("x", "z", "w", "y") # for ease, I'll use single letters > > > > > library(plotrix) > > > > > brkdn.plot(y~x+z, data=Q, > > > > >            pch = c(1, 16), cex = 1.5, type="p", > > > > >            main="Single Measurement", > > > > >            xlab=expression(bold("S1 nuclease")), > > > > >            ylab=expression(bold("Optical density"))) > > > > > brkdn.plot(y~x+z+w, data=Q, > > > > >            pch = c(1, 16), cex = 1.5, type="p", > > > > >            main="Double Measurement", > > > > >            xlab=expression(bold("S1 nuclease")), > > > > >            ylab=expression(bold("Optical density"))) > > > > > ``` > > > > > > > > > > ______________________________________________ > > > > > [hidden email] 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. > > > > > > > > > > > > -- > > > Best regards, > > > Luigi ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. lm_plot.png (25K) Download Attachment
Open this post in threaded view
|