plotting the regression coefficients

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

plotting the regression coefficients

greg holly
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
.
.

        [[alternative HTML version deleted]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

PIKAL Petr
Hi

Example, example, example - preferably working.

Wild guess - did you try ggplot?

Cheers
Petr


> -----Original Message-----
> From: R-help [mailto:[hidden email]] On Behalf Of greg holly
> Sent: Thursday, February 8, 2018 8:14 AM
> To: r-help mailing list <[hidden email]>
> 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
> .
> .
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [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.

________________________________
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.
______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

greg holly
 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 <[hidden email]> wrote:

> Hi
>
> Example, example, example - preferably working.
>
> Wild guess - did you try ggplot?
>
> Cheers
> Petr
>
>
> > -----Original Message-----
> > From: R-help [mailto:[hidden email]] On Behalf Of greg
> holly
> > Sent: Thursday, February 8, 2018 8:14 AM
> > To: r-help mailing list <[hidden email]>
> > 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
> > .
> > .
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [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.
>
> ________________________________
> 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]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

PIKAL Petr
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:[hidden email]]
Sent: Thursday, February 8, 2018 9:23 AM
To: PIKAL Petr <[hidden email]>
Cc: r-help mailing list <[hidden email]>
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 <[hidden email]<mailto:[hidden email]>> wrote:
Hi

Example, example, example - preferably working.

Wild guess - did you try ggplot?

Cheers
Petr


> -----Original Message-----
> From: R-help [mailto:[hidden email]<mailto:[hidden email]>] On Behalf Of greg holly
> Sent: Thursday, February 8, 2018 8:14 AM
> To: r-help mailing list <[hidden email]<mailto:[hidden email]>>
> 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
> .
> .
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email]<mailto:[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.

________________________________
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.


________________________________
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]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

Bert Gunter-2
In reply to this post by greg holly
Fwiw, encoding magnitude in color is generally a bad idea. Using area(*not*
radius) is also not great, but maybe it will work for you.

See here for some explanation:
https://www.amazon.com/Visual-Display-Quantitative-Information/dp/0961392142/ref=sr_1_1?s=books&ie=UTF8&qid=1518092778&sr=1-1&keywords=Tufte

Bert



On Feb 7, 2018 11:13 PM, "greg holly" <[hidden email]> wrote:

> 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
> .
> .
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [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.
>

        [[alternative HTML version deleted]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

greg holly
In reply to this post by PIKAL Petr
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 <[hidden email]> 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:[hidden email]]
> *Sent:* Thursday, February 8, 2018 9:23 AM
> *To:* PIKAL Petr <[hidden email]>
> *Cc:* r-help mailing list <[hidden email]>
> *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 <[hidden email]>
> wrote:
>
> Hi
>
> Example, example, example - preferably working.
>
> Wild guess - did you try ggplot?
>
> Cheers
> Petr
>
>
>
> > -----Original Message-----
> > From: R-help [mailto:[hidden email]] On Behalf Of greg
> holly
> > Sent: Thursday, February 8, 2018 8:14 AM
> > To: r-help mailing list <[hidden email]>
> > 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
> > .
> > .
> >
>
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [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.
>
> ________________________________
> 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.
>
>
>
> ------------------------------
> 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]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

greg holly
In reply to this post by Bert Gunter-2
Hi Bert;

Thanks so much for this. It is much appreciated.

Regards,
Greg

On Thu, Feb 8, 2018 at 3:29 PM, Bert Gunter <[hidden email]> wrote:

> Fwiw, encoding magnitude in color is generally a bad idea. Using
> area(*not* radius) is also not great, but maybe it will work for you.
>
> See here for some explanation: https://www.amazon.com/Visual-Display-
> Quantitative-Information/dp/0961392142/ref=sr_1_1?s=books&
> ie=UTF8&qid=1518092778&sr=1-1&keywords=Tufte
>
> Bert
>
>
>
> On Feb 7, 2018 11:13 PM, "greg holly" <[hidden email]> wrote:
>
>> 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
>> .
>> .
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [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/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

        [[alternative HTML version deleted]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

greg holly
In reply to this post by greg holly
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 <[hidden email]> 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 <[hidden email]> 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:[hidden email]]
>> *Sent:* Thursday, February 8, 2018 9:23 AM
>> *To:* PIKAL Petr <[hidden email]>
>> *Cc:* r-help mailing list <[hidden email]>
>> *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 <[hidden email]>
>> wrote:
>>
>> Hi
>>
>> Example, example, example - preferably working.
>>
>> Wild guess - did you try ggplot?
>>
>> Cheers
>> Petr
>>
>>
>>
>> > -----Original Message-----
>> > From: R-help [mailto:[hidden email]] On Behalf Of greg
>> holly
>> > Sent: Thursday, February 8, 2018 8:14 AM
>> > To: r-help mailing list <[hidden email]>
>> > 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
>> > .
>> > .
>> >
>>
>> > [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > [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/posti
>> ng-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> ________________________________
>> 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.
>>
>>
>>
>> ------------------------------
>> 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]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

PIKAL Petr
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:[hidden email]]
Sent: Saturday, February 10, 2018 9:05 PM
To: PIKAL Petr <[hidden email]>
Cc: r-help mailing list <[hidden email]>
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 <[hidden email]<mailto:[hidden email]>> 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 <[hidden email]<mailto:[hidden email]>> 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:[hidden email]<mailto:[hidden email]>]
Sent: Thursday, February 8, 2018 9:23 AM
To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
Cc: r-help mailing list <[hidden email]<mailto:[hidden email]>>
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 <[hidden email]<mailto:[hidden email]>> wrote:
Hi

Example, example, example - preferably working.

Wild guess - did you try ggplot?

Cheers
Petr


> -----Original Message-----
> From: R-help [mailto:[hidden email]<mailto:[hidden email]>] On Behalf Of greg holly
> Sent: Thursday, February 8, 2018 8:14 AM
> To: r-help mailing list <[hidden email]<mailto:[hidden email]>>
> 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
> .
> .
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email]<mailto:[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.

________________________________
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.


________________________________
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.



________________________________
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]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

greg holly
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 <[hidden email]> 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:[hidden email]]
> *Sent:* Saturday, February 10, 2018 9:05 PM
>
> *To:* PIKAL Petr <[hidden email]>
> *Cc:* r-help mailing list <[hidden email]>
> *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 <[hidden email]> 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 <[hidden email]> 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:[hidden email]]
> *Sent:* Thursday, February 8, 2018 9:23 AM
> *To:* PIKAL Petr <[hidden email]>
> *Cc:* r-help mailing list <[hidden email]>
> *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 <[hidden email]>
> wrote:
>
> Hi
>
> Example, example, example - preferably working.
>
> Wild guess - did you try ggplot?
>
> Cheers
> Petr
>
>
>
> > -----Original Message-----
> > From: R-help [mailto:[hidden email]] On Behalf Of greg
> holly
> > Sent: Thursday, February 8, 2018 8:14 AM
> > To: r-help mailing list <[hidden email]>
> > 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
> > .
> > .
> >
>
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [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.
>
> ________________________________
> 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.
>
>
>
>
> ------------------------------
>
> 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.
>
>
>
>
>
> ------------------------------
> 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]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

PIKAL Petr
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:[hidden email]]
Sent: Monday, February 12, 2018 8:52 AM
To: PIKAL Petr <[hidden email]>
Cc: r-help mailing list <[hidden email]>
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 <[hidden email]<mailto:[hidden email]>> 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:[hidden email]<mailto:[hidden email]>]
Sent: Saturday, February 10, 2018 9:05 PM

To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
Cc: r-help mailing list <[hidden email]<mailto:[hidden email]>>
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 <[hidden email]<mailto:[hidden email]>> 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 <[hidden email]<mailto:[hidden email]>> 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:[hidden email]<mailto:[hidden email]>]
Sent: Thursday, February 8, 2018 9:23 AM
To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
Cc: r-help mailing list <[hidden email]<mailto:[hidden email]>>
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 <[hidden email]<mailto:[hidden email]>> wrote:
Hi

Example, example, example - preferably working.

Wild guess - did you try ggplot?

Cheers
Petr


> -----Original Message-----
> From: R-help [mailto:[hidden email]<mailto:[hidden email]>] On Behalf Of greg holly
> Sent: Thursday, February 8, 2018 8:14 AM
> To: r-help mailing list <[hidden email]<mailto:[hidden email]>>
> 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]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

Richard M. Heiberger
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 <[hidden email]> 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:[hidden email]]
> Sent: Monday, February 12, 2018 8:52 AM
> To: PIKAL Petr <[hidden email]>
> Cc: r-help mailing list <[hidden email]>
> 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 <[hidden email]<mailto:[hidden email]>> 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:[hidden email]<mailto:[hidden email]>]
> Sent: Saturday, February 10, 2018 9:05 PM
>
> To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
> Cc: r-help mailing list <[hidden email]<mailto:[hidden email]>>
> 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 <[hidden email]<mailto:[hidden email]>> 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 <[hidden email]<mailto:[hidden email]>> 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:[hidden email]<mailto:[hidden email]>]
> Sent: Thursday, February 8, 2018 9:23 AM
> To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
> Cc: r-help mailing list <[hidden email]<mailto:[hidden email]>>
> 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 <[hidden email]<mailto:[hidden email]>> wrote:
> Hi
>
> Example, example, example - preferably working.
>
> Wild guess - did you try ggplot?
>
> Cheers
> Petr
>
>
>> -----Original Message-----
>> From: R-help [mailto:[hidden email]<mailto:[hidden email]>] On Behalf Of greg holly
>> Sent: Thursday, February 8, 2018 8:14 AM
>> To: r-help mailing list <[hidden email]<mailto:[hidden email]>>
>> 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]]
>
> ______________________________________________
> [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-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

greg holly
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 <[hidden email]>
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 <[hidden email]>
> 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:[hidden email]]
> > Sent: Monday, February 12, 2018 8:52 AM
> > To: PIKAL Petr <[hidden email]>
> > Cc: r-help mailing list <[hidden email]>
> > 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 <[hidden email]<
> mailto:[hidden email]>> 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:[hidden email]<mailto:
> [hidden email]>]
> > Sent: Saturday, February 10, 2018 9:05 PM
> >
> > To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
> > Cc: r-help mailing list <[hidden email]<mailto:r
> -[hidden email]>>
> > 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 <[hidden email]<mailto:
> [hidden email]>> 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 <[hidden email]<
> mailto:[hidden email]>> 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:[hidden email]<mailto:
> [hidden email]>]
> > Sent: Thursday, February 8, 2018 9:23 AM
> > To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
> > Cc: r-help mailing list <[hidden email]<mailto:r
> -[hidden email]>>
> > 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 <[hidden email]<
> mailto:[hidden email]>> wrote:
> > Hi
> >
> > Example, example, example - preferably working.
> >
> > Wild guess - did you try ggplot?
> >
> > Cheers
> > Petr
> >
> >
> >> -----Original Message-----
> >> From: R-help [mailto:[hidden email]<mailto:r-help-
> [hidden email]>] On Behalf Of greg holly
> >> Sent: Thursday, February 8, 2018 8:14 AM
> >> To: r-help mailing list <[hidden email]<mailto:r
> -[hidden email]>>
> >> 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]]
> >
> > ______________________________________________
> > [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.
>

        [[alternative HTML version deleted]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

PIKAL Petr
In reply to this post by Richard M. Heiberger
Hi Richard

Yes you are right, I did not check my answer enough.

Cheers
Petr

> -----Original Message-----
> From: Richard M. Heiberger [mailto:[hidden email]]
> Sent: Monday, February 12, 2018 6:10 PM
> To: PIKAL Petr <[hidden email]>
> Cc: greg holly <[hidden email]>; r-help mailing list <r-help@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 <[hidden email]> 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:[hidden email]]
> > Sent: Monday, February 12, 2018 8:52 AM
> > To: PIKAL Petr <[hidden email]>
> > Cc: r-help mailing list <[hidden email]>
> > 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
> <[hidden email]<mailto:[hidden email]>> 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:[hidden email]<mailto:[hidden email]>]
> > Sent: Saturday, February 10, 2018 9:05 PM
> >
> > To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
> > Cc: r-help mailing list
> > <[hidden email]<mailto:[hidden email]>>
> > 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
> <[hidden email]<mailto:[hidden email]>> 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
> <[hidden email]<mailto:[hidden email]>> 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:[hidden email]<mailto:[hidden email]>]
> > Sent: Thursday, February 8, 2018 9:23 AM
> > To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
> > Cc: r-help mailing list
> > <[hidden email]<mailto:[hidden email]>>
> > 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
> <[hidden email]<mailto:[hidden email]>> wrote:
> > Hi
> >
> > Example, example, example - preferably working.
> >
> > Wild guess - did you try ggplot?
> >
> > Cheers
> > Petr
> >
> >
> >> -----Original Message-----
> >> From: R-help
> >> [mailto:[hidden email]<mailto:r-help-bounces@r-project.
> >> org>] On Behalf Of greg holly
> >> Sent: Thursday, February 8, 2018 8:14 AM
> >> To: r-help mailing list
> >> <[hidden email]<mailto:[hidden email]>>
> >> 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.
______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

PIKAL Petr
In reply to this post by greg holly
Hi
scale_colour_gradient(“red”, “blue”)
should do the trick.
Actually I found it by Google
ggplot colour
http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/
http://www.sthda.com/english/wiki/ggplot2-colors-how-to-change-colors-automatically-and-manually#gradient-colors-for-scatter-plots
question. So you could find it too and probably far more quickly then myself as I have also other duties.
Cheers
Petr
BTW, you still post in HTML which could be sometimes problematic in this text only list.

From: greg holly [mailto:[hidden email]]
Sent: Monday, February 12, 2018 7:07 PM
To: Richard M. Heiberger <[hidden email]>
Cc: PIKAL Petr <[hidden email]>; r-help mailing list <[hidden email]>
Subject: Re: [R] plotting the regression coefficients

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 <[hidden email]<mailto:[hidden email]>> 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 <[hidden email]<mailto:[hidden email]>> 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:[hidden email]<mailto:[hidden email]>]
> Sent: Monday, February 12, 2018 8:52 AM
> To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
> Cc: r-help mailing list <[hidden email]<mailto:[hidden email]>>
> 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 <[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>> 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:[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>]
> Sent: Saturday, February 10, 2018 9:05 PM
>
> To: PIKAL Petr <[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>>
> Cc: r-help mailing list <[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>>
> 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 <[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>> 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 <[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>> 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:[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>]
> Sent: Thursday, February 8, 2018 9:23 AM
> To: PIKAL Petr <[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>>
> Cc: r-help mailing list <[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>>
> 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 <[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>> wrote:
> Hi
>
> Example, example, example - preferably working.
>
> Wild guess - did you try ggplot?
>
> Cheers
> Petr
>
>
>> -----Original Message-----
>> From: R-help [mailto:[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>] On Behalf Of greg holly
>> Sent: Thursday, February 8, 2018 8:14 AM
>> To: r-help mailing list <[hidden email]<mailto:[hidden email]><mailto:[hidden email]<mailto:[hidden email]>>>
>> 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]]

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|

Re: plotting the regression coefficients

greg holly
Hi Petr;

Thanks for this. I have used  scale_colour_gradient before but could not
get what I am looking for. I will check the links you provide to get Idea.
Once again thanks for your support and help.

Rgerads,
Greg



On Tue, Feb 13, 2018 at 5:34 PM, PIKAL Petr <[hidden email]> wrote:

> Hi
>
> scale_colour_gradient(“red”, “blue”)
>
> should do the trick.
>
> Actually I found it by Google
>
> ggplot colour
>
> http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/
>
> http://www.sthda.com/english/wiki/ggplot2-colors-how-to-
> change-colors-automatically-and-manually#gradient-colors-for-scatter-plots
>
> question. So you could find it too and probably far more quickly then
> myself as I have also other duties.
>
> Cheers
>
> Petr
>
> BTW, you still post in HTML which could be sometimes problematic in this
> text only list.
>
>
>
> *From:* greg holly [mailto:[hidden email]]
> *Sent:* Monday, February 12, 2018 7:07 PM
> *To:* Richard M. Heiberger <[hidden email]>
> *Cc:* PIKAL Petr <[hidden email]>; r-help mailing list <
> [hidden email]>
>
> *Subject:* Re: [R] plotting the regression coefficients
>
>
>
> 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 <[hidden email]>
> 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 <[hidden email]>
> 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:[hidden email]]
> > Sent: Monday, February 12, 2018 8:52 AM
> > To: PIKAL Petr <[hidden email]>
> > Cc: r-help mailing list <[hidden email]>
> > 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 <[hidden email]<
> mailto:[hidden email]>> 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:[hidden email]<mailto:
> [hidden email]>]
> > Sent: Saturday, February 10, 2018 9:05 PM
> >
> > To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
> > Cc: r-help mailing list <[hidden email]<mailto:r
> -[hidden email]>>
> > 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 <[hidden email]<mailto:
> [hidden email]>> 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 <[hidden email]<
> mailto:[hidden email]>> 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:[hidden email]<mailto:
> [hidden email]>]
> > Sent: Thursday, February 8, 2018 9:23 AM
> > To: PIKAL Petr <[hidden email]<mailto:[hidden email]>>
> > Cc: r-help mailing list <[hidden email]<mailto:r
> -[hidden email]>>
> > 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 <[hidden email]<
> mailto:[hidden email]>> wrote:
> > Hi
> >
> > Example, example, example - preferably working.
> >
> > Wild guess - did you try ggplot?
> >
> > Cheers
> > Petr
> >
> >
> >> -----Original Message-----
> >> From: R-help [mailto:[hidden email]<mailto:r-help-
> [hidden email]>] On Behalf Of greg holly
> >> Sent: Thursday, February 8, 2018 8:14 AM
>
> >> To: r-help mailing list <[hidden email]<mailto:r
> -[hidden email]>>
> >> 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]]

______________________________________________
[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.