Hi After melt you can change levels of your factor variable. Again with the toy example.> levels(temp$variable)[1] "y1" "y2" "y3" "y4"> levels(temp$variable) <- levels(temp$variable)[c(2,4,1,3)] > levels(temp$variable)[1] "y2" "y4" "y1" "y3">And you will get graphs with this new levels ordering. Cheers Petr From: greg holly [mailto:mak.hholly at gmail.com] Sent: Monday, February 12, 2018 8:52 AM To: PIKAL Petr <petr.pikal at precheza.cz> Cc: r-help mailing list <r-help at r-project.org> Subject: Re: [R] plotting the regression coefficients Hi Petr; Thanks so much. This is great! Although last Sunday, alternatively, I have solved the problem using the following statement at the very end of the program. ggsave('circle.pdf', p4, height = 70, width = 8, device=pdf, limitsize = F, dpi=300). This works very well too. Asa my categorical variables are in my Y axis, my R program reorders the names on Y-axis. However, I would like have and plot output with the names as they are. Is there any way to have plot without ordering the names of variables on Y-axis? Regards, Greg. On Mon, Feb 12, 2018 at 10:12 AM, PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote: Hi Maybe there are other ways but I would split data to several chunks e.g. in list and use for cycle to fill multipage pdf. With the toy data something like library(reshape2) library(ggplot2) temp <- melt(temp) temp.s<-split(temp, cut(1:nrow(temp), 2)) pdf("temp.pdf") for (i in 1: length(temp.s)) { p <- ggplot(temp.s[[i]], aes(x=par1, y=variable, size=abs(value), colour=factor(sign(value)))) print(p+geom_point()) } dev.off() But the real code partly depends on your real data. Cheers Petr From: greg holly [mailto:mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>] Sent: Saturday, February 10, 2018 9:05 PM To: PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> Cc: r-help mailing list <r-help at r-project.org<mailto:r-help at r-project.org>> Subject: Re: [R] plotting the regression coefficients Hi Peter; The R code you provided works very well. Once again thanks so much for this. The number of variables in my data set that should appear on the y-axis is 733 and they are not numerical (for example the name of one variable is palmitoyl-arachidonoyl-glycerol (16:0/20:4) [1]*. So, the plot looks very messy in one page. How can I make the plot to print out on multiple pages? Regards, Greg On Thu, Feb 8, 2018 at 4:33 PM, greg holly <mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>> wrote: Hi Petr; Thanks so much. Exactly this is what I need. I will play to change color and so on but this backbound is perfect to me. I do appreciate your help and support. Regards, Greg On Thu, Feb 8, 2018 at 1:29 PM, PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote: Hi I copied your values to R, here it is> dput(temp)temp <- structure(list(par1 = structure(1:4, .Label = c("x1", "x2", "x3", "x4"), class = "factor"), y1 = c(-0.19, 0.45, -0.09, -0.16), y2 = c(0.4, -0.75, 0.14, -0.01), y3 = c(-0.06, -8.67, 1.42, 2.21), y4 = c(0.13, -0.46, 0.06, 0.06)), .Names = c("par1", "y1", "y2", "y3", "y4"), class = "data.frame", row.names = c(NA, -4L)) For plotting it need to be reshaped library(reshape2) library(ggplot2) temp <- melt(temp) p <- ggplot(temp, aes(x=par1, y=variable, size=abs(value), colour=factor(sign(value)))) p+geom_point() Is this what you wanted? Cheers Petr And preferably do not post in HTML, the email content could be scrambled. From: greg holly [mailto:mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>] Sent: Thursday, February 8, 2018 9:23 AM To: PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> Cc: r-help mailing list <r-help at r-project.org<mailto:r-help at r-project.org>> Subject: Re: [R] plotting the regression coefficients Hi Petr; Thanks for your reply. It is much appreciated. A small example is given below for 4 independent and 4 dependent variables only. The values given are regression coefficients.I have looked ggplot documents before writing to you. Unfortunately, I could not figure out as my experience in ggplot is ignorable Regards. Greg y1 y2 y3 y4 x1 -0.19 0.40 -0.06 0.13 x2 0.45 -0.75 -8.67 -0.46 x3 -0.09 0.14 1.42 0.06 x4 -0.16 -0.01 2.21 0.06 On Thu, Feb 8, 2018 at 10:19 AM, PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote: Hi Example, example, example - preferably working. Wild guess - did you try ggplot? Cheers Petr> -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org<mailto:r-help-bounces at r-project.org>] On Behalf Of greg holly > Sent: Thursday, February 8, 2018 8:14 AM > To: r-help mailing list <r-help at r-project.org<mailto:r-help at r-project.org>> > Subject: [R] plotting the regression coefficients > > Hi Dear all; > > I would like to create a plot for regression coefficients with each independent > variable (x) along the side and the phenotypes (y) across the top (as given > below). For each data point, direction and magnitude of effect could be color > and significance could be the size of the circle? Is this possible? > > > I would greatly be appreciated your help. > > Thanks, > > Greg > > > > y1 y2 y3 y4 y5 y6 > x1 > x2 > x3 > x4 > x5 > x6 > x7 > x8 > x9 > x10 > x11 > x12 > x13 > x14 > x15 > x16 > x17 > . > . >________________________________ Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou ur?eny pouze jeho adres?t?m. Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze sv?ho syst?mu. Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat. Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi ?i zpo?d?n?m p?enosu e-mailu. V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?: - vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu. - a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout; Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany p??jemce s dodatkem ?i odchylkou. - trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech. - odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich existence je adres?tovi ?i osob? j?m zastoupen? zn?m?. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient. [[alternative HTML version deleted]]
Petr, there was a thinko in your response. tmp <- data.frame(m=factor(letters[1:4]), n=1:4) tmp tmp$m <- factor(tmp$m, levels=c("c","b","a","d")) ## right tmp[order(tmp$m),] tmp <- data.frame(m=factor(letters[1:4]), n=1:4) levels(tmp$m) <- c("c","b","a","d") ## wrong tmp[order(tmp$m),] changing levels directly changes the names only, not the ordering. You must redefine the factor to retain the relationship of factor names with the numerical values. Rich On Mon, Feb 12, 2018 at 3:49 AM, PIKAL Petr <petr.pikal at precheza.cz> wrote:> Hi > > After melt you can change levels of your factor variable. Again with the toy example. > >> levels(temp$variable) > [1] "y1" "y2" "y3" "y4" >> levels(temp$variable) <- levels(temp$variable)[c(2,4,1,3)] >> levels(temp$variable) > [1] "y2" "y4" "y1" "y3" >> > > And you will get graphs with this new levels ordering. > > Cheers > Petr > > From: greg holly [mailto:mak.hholly at gmail.com] > Sent: Monday, February 12, 2018 8:52 AM > To: PIKAL Petr <petr.pikal at precheza.cz> > Cc: r-help mailing list <r-help at r-project.org> > Subject: Re: [R] plotting the regression coefficients > > Hi Petr; > > Thanks so much. This is great! Although last Sunday, alternatively, I have solved the problem using the following statement at the very end of the program. > > ggsave('circle.pdf', p4, height = 70, width = 8, device=pdf, limitsize = F, dpi=300). > > This works very well too. > > Asa my categorical variables are in my Y axis, my R program reorders the names on Y-axis. However, I would like have and plot output with the names as they are. Is there any way to have plot without ordering the names of variables on Y-axis? > > Regards, > Greg. > > On Mon, Feb 12, 2018 at 10:12 AM, PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote: > Hi > > Maybe there are other ways but I would split data to several chunks e.g. in list and use for cycle to fill multipage pdf. > > With the toy data something like > > library(reshape2) > library(ggplot2) > temp <- melt(temp) > temp.s<-split(temp, cut(1:nrow(temp), 2)) > > pdf("temp.pdf") > for (i in 1: length(temp.s)) { > p <- ggplot(temp.s[[i]], aes(x=par1, y=variable, size=abs(value), colour=factor(sign(value)))) > print(p+geom_point()) > } > dev.off() > > But the real code partly depends on your real data. > > Cheers > Petr > > From: greg holly [mailto:mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>] > Sent: Saturday, February 10, 2018 9:05 PM > > To: PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> > Cc: r-help mailing list <r-help at r-project.org<mailto:r-help at r-project.org>> > Subject: Re: [R] plotting the regression coefficients > > Hi Peter; > > The R code you provided works very well. Once again thanks so much for this. The number of variables in my data set that should appear on the y-axis is 733 and they are not numerical (for example the name of one variable is palmitoyl-arachidonoyl-glycerol (16:0/20:4) [1]*. So, the plot looks very messy in one page. How can I make the plot to print out on multiple pages? > > Regards, > > Greg > > On Thu, Feb 8, 2018 at 4:33 PM, greg holly <mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>> wrote: > Hi Petr; > > Thanks so much. Exactly this is what I need. I will play to change color and so on but this backbound is perfect to me. I do appreciate your help and support. > > Regards, > Greg > > On Thu, Feb 8, 2018 at 1:29 PM, PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote: > Hi > I copied your values to R, here it is > >> dput(temp) > > temp <- structure(list(par1 = structure(1:4, .Label = c("x1", "x2", "x3", > "x4"), class = "factor"), y1 = c(-0.19, 0.45, -0.09, -0.16), > y2 = c(0.4, -0.75, 0.14, -0.01), y3 = c(-0.06, -8.67, 1.42, > 2.21), y4 = c(0.13, -0.46, 0.06, 0.06)), .Names = c("par1", > "y1", "y2", "y3", "y4"), class = "data.frame", row.names = c(NA, > -4L)) > > For plotting it need to be reshaped > > library(reshape2) > library(ggplot2) > > temp <- melt(temp) > p <- ggplot(temp, aes(x=par1, y=variable, size=abs(value), colour=factor(sign(value)))) > p+geom_point() > > Is this what you wanted? > > Cheers > Petr > And preferably do not post in HTML, the email content could be scrambled. > > From: greg holly [mailto:mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>] > Sent: Thursday, February 8, 2018 9:23 AM > To: PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> > Cc: r-help mailing list <r-help at r-project.org<mailto:r-help at r-project.org>> > Subject: Re: [R] plotting the regression coefficients > > Hi Petr; > > Thanks for your reply. It is much appreciated. A small example is given below for 4 independent and 4 dependent variables only. The values given are regression coefficients.I have looked ggplot documents before writing to you. Unfortunately, I could not figure out as my experience in ggplot is ignorable > > Regards. > Greg > > y1 y2 y3 y4 > x1 -0.19 0.40 -0.06 0.13 > x2 0.45 -0.75 -8.67 -0.46 > x3 -0.09 0.14 1.42 0.06 > x4 -0.16 -0.01 2.21 0.06 > > > On Thu, Feb 8, 2018 at 10:19 AM, PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote: > Hi > > Example, example, example - preferably working. > > Wild guess - did you try ggplot? > > Cheers > Petr > > >> -----Original Message----- >> From: R-help [mailto:r-help-bounces at r-project.org<mailto:r-help-bounces at r-project.org>] On Behalf Of greg holly >> Sent: Thursday, February 8, 2018 8:14 AM >> To: r-help mailing list <r-help at r-project.org<mailto:r-help at r-project.org>> >> Subject: [R] plotting the regression coefficients >> >> Hi Dear all; >> >> I would like to create a plot for regression coefficients with each independent >> variable (x) along the side and the phenotypes (y) across the top (as given >> below). For each data point, direction and magnitude of effect could be color >> and significance could be the size of the circle? Is this possible? >> >> >> I would greatly be appreciated your help. >> >> Thanks, >> >> Greg >> >> >> >> y1 y2 y3 y4 y5 y6 >> x1 >> x2 >> x3 >> x4 >> x5 >> x6 >> x7 >> x8 >> x9 >> x10 >> x11 >> x12 >> x13 >> x14 >> x15 >> x16 >> x17 >> . >> . >> > > > ________________________________ > Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou ur?eny pouze jeho adres?t?m. > Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze sv?ho syst?mu. > Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat. > Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi ?i zpo?d?n?m p?enosu e-mailu. > > V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?: > - vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu. > - a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout; Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany p??jemce s dodatkem ?i odchylkou. > - trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech. > - odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich existence je adres?tovi ?i osob? j?m zastoupen? zn?m?. > > This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. > If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. > If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. > The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. > > In case that this e-mail forms part of business dealings: > - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. > - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. > - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. > - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient. > > [[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.
Hi Petr and Richard; Thanks for your responses and supports. I just faced a different problem. I have the following R codes and work well. p <- ggplot(a, aes(x=Phenotypes, y=Metabolites, size=abs(Beta), colour=factor(sign(Beta)))) + theme(axis.text=element_text(size = 5)) p1<-p+geom_point() p2<-p1+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), axis.ticks = element_blank()) p3<-p2+theme(panel.grid.major = element_blank(), panel.grid.minor element_blank(), panel.background = element_blank(), axis.line = element_line(colour "black")) p4<-p3+scale_color_manual(breaks = c("-1", "0", "1"), values=c("darkblue", "green", "red")) *My question is:* What if I was to repeat the analysis and standardize the beta (z-score) so they are comparable across phenotypes (I have 8 phenotypes). We could then ?bin? the betas to represent shades of red and blue. Regards, Greg On Mon, Feb 12, 2018 at 8:10 PM, Richard M. Heiberger <rmh at temple.edu> wrote:> Petr, there was a thinko in your response. > > > tmp <- data.frame(m=factor(letters[1:4]), n=1:4) > tmp > tmp$m <- factor(tmp$m, levels=c("c","b","a","d")) ## right > tmp[order(tmp$m),] > > tmp <- data.frame(m=factor(letters[1:4]), n=1:4) > levels(tmp$m) <- c("c","b","a","d") ## wrong > tmp[order(tmp$m),] > > changing levels directly changes the names only, not the ordering. > You must redefine the factor to retain the relationship of factor > names with the numerical values. > > Rich > > > On Mon, Feb 12, 2018 at 3:49 AM, PIKAL Petr <petr.pikal at precheza.cz> > wrote: > > Hi > > > > After melt you can change levels of your factor variable. Again with the > toy example. > > > >> levels(temp$variable) > > [1] "y1" "y2" "y3" "y4" > >> levels(temp$variable) <- levels(temp$variable)[c(2,4,1,3)] > >> levels(temp$variable) > > [1] "y2" "y4" "y1" "y3" > >> > > > > And you will get graphs with this new levels ordering. > > > > Cheers > > Petr > > > > From: greg holly [mailto:mak.hholly at gmail.com] > > Sent: Monday, February 12, 2018 8:52 AM > > To: PIKAL Petr <petr.pikal at precheza.cz> > > Cc: r-help mailing list <r-help at r-project.org> > > Subject: Re: [R] plotting the regression coefficients > > > > Hi Petr; > > > > Thanks so much. This is great! Although last Sunday, alternatively, I > have solved the problem using the following statement at the very end of > the program. > > > > ggsave('circle.pdf', p4, height = 70, width = 8, device=pdf, limitsize > = F, dpi=300). > > > > This works very well too. > > > > Asa my categorical variables are in my Y axis, my R program reorders the > names on Y-axis. However, I would like have and plot output with the names > as they are. Is there any way to have plot without ordering the names of > variables on Y-axis? > > > > Regards, > > Greg. > > > > On Mon, Feb 12, 2018 at 10:12 AM, PIKAL Petr <petr.pikal at precheza.cz< > mailto:petr.pikal at precheza.cz>> wrote: > > Hi > > > > Maybe there are other ways but I would split data to several chunks e.g. > in list and use for cycle to fill multipage pdf. > > > > With the toy data something like > > > > library(reshape2) > > library(ggplot2) > > temp <- melt(temp) > > temp.s<-split(temp, cut(1:nrow(temp), 2)) > > > > pdf("temp.pdf") > > for (i in 1: length(temp.s)) { > > p <- ggplot(temp.s[[i]], aes(x=par1, y=variable, size=abs(value), > colour=factor(sign(value)))) > > print(p+geom_point()) > > } > > dev.off() > > > > But the real code partly depends on your real data. > > > > Cheers > > Petr > > > > From: greg holly [mailto:mak.hholly at gmail.com<mailto: > mak.hholly at gmail.com>] > > Sent: Saturday, February 10, 2018 9:05 PM > > > > To: PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> > > Cc: r-help mailing list <r-help at r-project.org<mailto:r > -help at r-project.org>> > > Subject: Re: [R] plotting the regression coefficients > > > > Hi Peter; > > > > The R code you provided works very well. Once again thanks so much for > this. The number of variables in my data set that should appear on the > y-axis is 733 and they are not numerical (for example the name of one > variable is palmitoyl-arachidonoyl-glycerol (16:0/20:4) [1]*. So, the > plot looks very messy in one page. How can I make the plot to print out on > multiple pages? > > > > Regards, > > > > Greg > > > > On Thu, Feb 8, 2018 at 4:33 PM, greg holly <mak.hholly at gmail.com<mailto: > mak.hholly at gmail.com>> wrote: > > Hi Petr; > > > > Thanks so much. Exactly this is what I need. I will play to change color > and so on but this backbound is perfect to me. I do appreciate your help > and support. > > > > Regards, > > Greg > > > > On Thu, Feb 8, 2018 at 1:29 PM, PIKAL Petr <petr.pikal at precheza.cz< > mailto:petr.pikal at precheza.cz>> wrote: > > Hi > > I copied your values to R, here it is > > > >> dput(temp) > > > > temp <- structure(list(par1 = structure(1:4, .Label = c("x1", "x2", "x3", > > "x4"), class = "factor"), y1 = c(-0.19, 0.45, -0.09, -0.16), > > y2 = c(0.4, -0.75, 0.14, -0.01), y3 = c(-0.06, -8.67, 1.42, > > 2.21), y4 = c(0.13, -0.46, 0.06, 0.06)), .Names = c("par1", > > "y1", "y2", "y3", "y4"), class = "data.frame", row.names = c(NA, > > -4L)) > > > > For plotting it need to be reshaped > > > > library(reshape2) > > library(ggplot2) > > > > temp <- melt(temp) > > p <- ggplot(temp, aes(x=par1, y=variable, size=abs(value), > colour=factor(sign(value)))) > > p+geom_point() > > > > Is this what you wanted? > > > > Cheers > > Petr > > And preferably do not post in HTML, the email content could be scrambled. > > > > From: greg holly [mailto:mak.hholly at gmail.com<mailto: > mak.hholly at gmail.com>] > > Sent: Thursday, February 8, 2018 9:23 AM > > To: PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> > > Cc: r-help mailing list <r-help at r-project.org<mailto:r > -help at r-project.org>> > > Subject: Re: [R] plotting the regression coefficients > > > > Hi Petr; > > > > Thanks for your reply. It is much appreciated. A small example is given > below for 4 independent and 4 dependent variables only. The values given > are regression coefficients.I have looked ggplot documents before writing > to you. Unfortunately, I could not figure out as my experience in ggplot is > ignorable > > > > Regards. > > Greg > > > > y1 y2 y3 y4 > > x1 -0.19 0.40 -0.06 0.13 > > x2 0.45 -0.75 -8.67 -0.46 > > x3 -0.09 0.14 1.42 0.06 > > x4 -0.16 -0.01 2.21 0.06 > > > > > > On Thu, Feb 8, 2018 at 10:19 AM, PIKAL Petr <petr.pikal at precheza.cz< > mailto:petr.pikal at precheza.cz>> wrote: > > Hi > > > > Example, example, example - preferably working. > > > > Wild guess - did you try ggplot? > > > > Cheers > > Petr > > > > > >> -----Original Message----- > >> From: R-help [mailto:r-help-bounces at r-project.org<mailto:r-help- > bounces at r-project.org>] On Behalf Of greg holly > >> Sent: Thursday, February 8, 2018 8:14 AM > >> To: r-help mailing list <r-help at r-project.org<mailto:r > -help at r-project.org>> > >> Subject: [R] plotting the regression coefficients > >> > >> Hi Dear all; > >> > >> I would like to create a plot for regression coefficients with each > independent > >> variable (x) along the side and the phenotypes (y) across the top (as > given > >> below). For each data point, direction and magnitude of effect could be > color > >> and significance could be the size of the circle? Is this possible? > >> > >> > >> I would greatly be appreciated your help. > >> > >> Thanks, > >> > >> Greg > >> > >> > >> > >> y1 y2 y3 y4 y5 y6 > >> x1 > >> x2 > >> x3 > >> x4 > >> x5 > >> x6 > >> x7 > >> x8 > >> x9 > >> x10 > >> x11 > >> x12 > >> x13 > >> x14 > >> x15 > >> x16 > >> x17 > >> . > >> . > >> > > > > > > ________________________________ > > Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou > ur?eny pouze jeho adres?t?m. > > Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? > neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie > vyma?te ze sv?ho syst?mu. > > Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento > email jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat. > > Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou > modifikacemi ?i zpo?d?n?m p?enosu e-mailu. > > > > V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?: > > - vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? > smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu. > > - a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? > p?ijmout; Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze > strany p??jemce s dodatkem ?i odchylkou. > > - trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve > v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech. > > - odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za > spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n > nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto > emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich > existence je adres?tovi ?i osob? j?m zastoupen? zn?m?. > > > > This e-mail and any documents attached to it may be confidential and are > intended only for its intended recipients. > > If you received this e-mail by mistake, please immediately inform its > sender. Delete the contents of this e-mail with all attachments and its > copies from your system. > > If you are not the intended recipient of this e-mail, you are not > authorized to use, disseminate, copy or disclose this e-mail in any manner. > > The sender of this e-mail shall not be liable for any possible damage > caused by modifications of the e-mail or by delay with transfer of the > email. > > > > In case that this e-mail forms part of business dealings: > > - the sender reserves the right to end negotiations about entering into > a contract in any time, for any reason, and without stating any reasoning. > > - if the e-mail contains an offer, the recipient is entitled to > immediately accept such offer; The sender of this e-mail (offer) excludes > any acceptance of the offer on the part of the recipient containing any > amendment or variation. > > - the sender insists on that the respective contract is concluded only > upon an express mutual agreement on all its aspects. > > - the sender of this e-mail informs that he/she is not authorized to > enter into any contracts on behalf of the company except for cases in which > he/she is expressly authorized to do so in writing, and such authorization > or power of attorney is submitted to the recipient or the person > represented by the recipient, or the existence of such authorization is > known to the recipient of the person represented by the recipient. > > > > [[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. >[[alternative HTML version deleted]]
Hi Richard Yes you are right, I did not check my answer enough. Cheers Petr> -----Original Message----- > From: Richard M. Heiberger [mailto:rmh at temple.edu] > Sent: Monday, February 12, 2018 6:10 PM > To: PIKAL Petr <petr.pikal at precheza.cz> > Cc: greg holly <mak.hholly at gmail.com>; r-help mailing list <r-help at r- > project.org> > Subject: Re: [R] plotting the regression coefficients > > Petr, there was a thinko in your response. > > > tmp <- data.frame(m=factor(letters[1:4]), n=1:4) tmp tmp$m <- factor(tmp$m, > levels=c("c","b","a","d")) ## right tmp[order(tmp$m),] > > tmp <- data.frame(m=factor(letters[1:4]), n=1:4) > levels(tmp$m) <- c("c","b","a","d") ## wrong tmp[order(tmp$m),] > > changing levels directly changes the names only, not the ordering. > You must redefine the factor to retain the relationship of factor names with the > numerical values. > > Rich > > > On Mon, Feb 12, 2018 at 3:49 AM, PIKAL Petr <petr.pikal at precheza.cz> wrote: > > Hi > > > > After melt you can change levels of your factor variable. Again with the toy > example. > > > >> levels(temp$variable) > > [1] "y1" "y2" "y3" "y4" > >> levels(temp$variable) <- levels(temp$variable)[c(2,4,1,3)] > >> levels(temp$variable) > > [1] "y2" "y4" "y1" "y3" > >> > > > > And you will get graphs with this new levels ordering. > > > > Cheers > > Petr > > > > From: greg holly [mailto:mak.hholly at gmail.com] > > Sent: Monday, February 12, 2018 8:52 AM > > To: PIKAL Petr <petr.pikal at precheza.cz> > > Cc: r-help mailing list <r-help at r-project.org> > > Subject: Re: [R] plotting the regression coefficients > > > > Hi Petr; > > > > Thanks so much. This is great! Although last Sunday, alternatively, I have > solved the problem using the following statement at the very end of the > program. > > > > ggsave('circle.pdf', p4, height = 70, width = 8, device=pdf, limitsize = F, > dpi=300). > > > > This works very well too. > > > > Asa my categorical variables are in my Y axis, my R program reorders the > names on Y-axis. However, I would like have and plot output with the names as > they are. Is there any way to have plot without ordering the names of variables > on Y-axis? > > > > Regards, > > Greg. > > > > On Mon, Feb 12, 2018 at 10:12 AM, PIKAL Petr > <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote: > > Hi > > > > Maybe there are other ways but I would split data to several chunks e.g. in > list and use for cycle to fill multipage pdf. > > > > With the toy data something like > > > > library(reshape2) > > library(ggplot2) > > temp <- melt(temp) > > temp.s<-split(temp, cut(1:nrow(temp), 2)) > > > > pdf("temp.pdf") > > for (i in 1: length(temp.s)) { > > p <- ggplot(temp.s[[i]], aes(x=par1, y=variable, size=abs(value), > > colour=factor(sign(value)))) > > print(p+geom_point()) > > } > > dev.off() > > > > But the real code partly depends on your real data. > > > > Cheers > > Petr > > > > From: greg holly > > [mailto:mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>] > > Sent: Saturday, February 10, 2018 9:05 PM > > > > To: PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> > > Cc: r-help mailing list > > <r-help at r-project.org<mailto:r-help at r-project.org>> > > Subject: Re: [R] plotting the regression coefficients > > > > Hi Peter; > > > > The R code you provided works very well. Once again thanks so much for this. > The number of variables in my data set that should appear on the y-axis is 733 > and they are not numerical (for example the name of one variable is palmitoyl- > arachidonoyl-glycerol (16:0/20:4) [1]*. So, the plot looks very messy in one > page. How can I make the plot to print out on multiple pages? > > > > Regards, > > > > Greg > > > > On Thu, Feb 8, 2018 at 4:33 PM, greg holly > <mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>> wrote: > > Hi Petr; > > > > Thanks so much. Exactly this is what I need. I will play to change color and so > on but this backbound is perfect to me. I do appreciate your help and support. > > > > Regards, > > Greg > > > > On Thu, Feb 8, 2018 at 1:29 PM, PIKAL Petr > <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote: > > Hi > > I copied your values to R, here it is > > > >> dput(temp) > > > > temp <- structure(list(par1 = structure(1:4, .Label = c("x1", "x2", > > "x3", "x4"), class = "factor"), y1 = c(-0.19, 0.45, -0.09, -0.16), > > y2 = c(0.4, -0.75, 0.14, -0.01), y3 = c(-0.06, -8.67, 1.42, > > 2.21), y4 = c(0.13, -0.46, 0.06, 0.06)), .Names = c("par1", "y1", > > "y2", "y3", "y4"), class = "data.frame", row.names = c(NA, > > -4L)) > > > > For plotting it need to be reshaped > > > > library(reshape2) > > library(ggplot2) > > > > temp <- melt(temp) > > p <- ggplot(temp, aes(x=par1, y=variable, size=abs(value), > > colour=factor(sign(value)))) > > p+geom_point() > > > > Is this what you wanted? > > > > Cheers > > Petr > > And preferably do not post in HTML, the email content could be scrambled. > > > > From: greg holly > > [mailto:mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>] > > Sent: Thursday, February 8, 2018 9:23 AM > > To: PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> > > Cc: r-help mailing list > > <r-help at r-project.org<mailto:r-help at r-project.org>> > > Subject: Re: [R] plotting the regression coefficients > > > > Hi Petr; > > > > Thanks for your reply. It is much appreciated. A small example is > > given below for 4 independent and 4 dependent variables only. The > > values given are regression coefficients.I have looked ggplot > > documents before writing to you. Unfortunately, I could not figure out > > as my experience in ggplot is ignorable > > > > Regards. > > Greg > > > > y1 y2 y3 y4 > > x1 -0.19 0.40 -0.06 0.13 > > x2 0.45 -0.75 -8.67 -0.46 > > x3 -0.09 0.14 1.42 0.06 > > x4 -0.16 -0.01 2.21 0.06 > > > > > > On Thu, Feb 8, 2018 at 10:19 AM, PIKAL Petr > <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote: > > Hi > > > > Example, example, example - preferably working. > > > > Wild guess - did you try ggplot? > > > > Cheers > > Petr > > > > > >> -----Original Message----- > >> From: R-help > >> [mailto:r-help-bounces at r-project.org<mailto:r-help-bounces at r-project. > >> org>] On Behalf Of greg holly > >> Sent: Thursday, February 8, 2018 8:14 AM > >> To: r-help mailing list > >> <r-help at r-project.org<mailto:r-help at r-project.org>> > >> Subject: [R] plotting the regression coefficients > >> > >> Hi Dear all; > >> > >> I would like to create a plot for regression coefficients with each > >> independent variable (x) along the side and the phenotypes (y) across > >> the top (as given below). For each data point, direction and > >> magnitude of effect could be color and significance could be the size of the > circle? Is this possible? > >> > >> > >> I would greatly be appreciated your help. > >> > >> Thanks, > >> > >> Greg > >> > >> > >> > >> y1 y2 y3 y4 y5 y6 > >> x1 > >> x2 > >> x3 > >> x4 > >> x5 > >> x6 > >> x7 > >> x8 > >> x9 > >> x10 > >> x11 > >> x12 > >> x13 > >> x14 > >> x15 > >> x16 > >> x17 > >> . > >> . > >> > > > >________________________________ Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou ur?eny pouze jeho adres?t?m. Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze sv?ho syst?mu. Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat. Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi ?i zpo?d?n?m p?enosu e-mailu. V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?: - vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu. - a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout; Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany p??jemce s dodatkem ?i odchylkou. - trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech. - odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich existence je adres?tovi ?i osob? j?m zastoupen? zn?m?. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.