how do I add text lables on QQ plot

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

how do I add text lables on QQ plot

anikaM
Hello,

I am making QQ plot via:

library(ggman)
qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17,
col=fdr1_sorted$group, cex = 1, las = 1)

data frames used look like this:

> head(fdr1_sorted)
                                       NAME             GS<br> follow
link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
1:                 GO_DNA_PACKAGING_COMPLEX
GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
0
2:                   GO_PROTEIN_DNA_COMPLEX
GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
        0
4:          GO_RESPONSE_TO_INTERFERON_GAMMA
GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
       0
5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
-2.402153         0
6:                 GO_GRANULOCYTE_MIGRATION
GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
0
   FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
group FDR.q.val2
1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
    2      1e-10
2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
    2      1e-10
3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
    4      1e-10
4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
    4      1e-10
5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
    4      1e-10
6:         0          0         491  tags=28%, list=4%, signal=29%  NA
    4      1e-10

> head(fdr2_sorted)
                                       NAME             GS<br> follow
link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
1:                 GO_DNA_PACKAGING_COMPLEX
GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
0
2:                   GO_PROTEIN_DNA_COMPLEX
GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
        0
4:          GO_RESPONSE_TO_INTERFERON_GAMMA
GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
       0
5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
-2.402153         0
6:                 GO_GRANULOCYTE_MIGRATION
GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
0
   FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
FDR.q.val2
1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
     1e-10
2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
     1e-10
3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
     1e-10
4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
     1e-10
5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
     1e-10
6:         0          0         491  tags=28%, list=4%, signal=29%  NA
     1e-10

and I would like to get the plot like the one in attach.

Please advise,
Ana

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

rsz_qqanot.png (102K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how do I add text lables on QQ plot

Abby Spurdle
> and I would like to get the plot like the one in attach.
> Please advise,

This is a bad idea.
Plots should be *easy* to interpret.

Try to keep plots relatively simple, avoiding unnecessary details.
For nontrivial plots, use a caption to describe the main features of the plot.
(That's where your text should go).

I note that you've asked a number of questions about QQ plots.
I'd recommend that you use QQ plots in a standard way, without
frequently trying to modify/customize them.

______________________________________________
[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: how do I add text lables on QQ plot

anikaM
Thanks for getting back to me but I would need this text labels added in
this particular instance

On Wed, 11 Mar 2020 at 19:37, Abby Spurdle <[hidden email]> wrote:

> > and I would like to get the plot like the one in attach.
> > Please advise,
>
> This is a bad idea.
> Plots should be *easy* to interpret.
>
> Try to keep plots relatively simple, avoiding unnecessary details.
> For nontrivial plots, use a caption to describe the main features of the
> plot.
> (That's where your text should go).
>
> I note that you've asked a number of questions about QQ plots.
> I'd recommend that you use QQ plots in a standard way, without
> frequently trying to modify/customize them.
>

        [[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: how do I add text lables on QQ plot

Abby Spurdle
Ok, then.

What graphics system is the qq function using?
Assuming that it's using the base graphics system, look at the
graphics::text function.

text (1:10, 1:10, LETTERS [1:10])

If it's a different graphics system, then I don't know, but hopefully
someone else will help.

On Thu, Mar 12, 2020 at 1:48 PM Ana Marija <[hidden email]> wrote:

>
> Thanks for getting back to me but I would need this text labels added in this particular instance
>
> On Wed, 11 Mar 2020 at 19:37, Abby Spurdle <[hidden email]> wrote:
>>
>> > and I would like to get the plot like the one in attach.
>> > Please advise,
>>
>> This is a bad idea.
>> Plots should be *easy* to interpret.
>>
>> Try to keep plots relatively simple, avoiding unnecessary details.
>> For nontrivial plots, use a caption to describe the main features of the plot.
>> (That's where your text should go).
>>
>> I note that you've asked a number of questions about QQ plots.
>> I'd recommend that you use QQ plots in a standard way, without
>> frequently trying to modify/customize them.

______________________________________________
[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: how do I add text lables on QQ plot

Abby Spurdle
One more thing, I can't find a CRAN package named "ggman".

On Thu, Mar 12, 2020 at 1:59 PM Abby Spurdle <[hidden email]> wrote:

>
> Ok, then.
>
> What graphics system is the qq function using?
> Assuming that it's using the base graphics system, look at the
> graphics::text function.
>
> text (1:10, 1:10, LETTERS [1:10])
>
> If it's a different graphics system, then I don't know, but hopefully
> someone else will help.
>
> On Thu, Mar 12, 2020 at 1:48 PM Ana Marija <[hidden email]> wrote:
> >
> > Thanks for getting back to me but I would need this text labels added in this particular instance
> >
> > On Wed, 11 Mar 2020 at 19:37, Abby Spurdle <[hidden email]> wrote:
> >>
> >> > and I would like to get the plot like the one in attach.
> >> > Please advise,
> >>
> >> This is a bad idea.
> >> Plots should be *easy* to interpret.
> >>
> >> Try to keep plots relatively simple, avoiding unnecessary details.
> >> For nontrivial plots, use a caption to describe the main features of the plot.
> >> (That's where your text should go).
> >>
> >> I note that you've asked a number of questions about QQ plots.
> >> I'd recommend that you use QQ plots in a standard way, without
> >> frequently trying to modify/customize them.

______________________________________________
[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: how do I add text lables on QQ plot

John Kane-3
No idua how it works but the name suggests it in out of the Hadley universe
and not basic graphics.

On Wed, 11 Mar 2020 at 21:14, Abby Spurdle <[hidden email]> wrote:

> One more thing, I can't find a CRAN package named "ggman".
>
> On Thu, Mar 12, 2020 at 1:59 PM Abby Spurdle <[hidden email]> wrote:
> >
> > Ok, then.
> >
> > What graphics system is the qq function using?
> > Assuming that it's using the base graphics system, look at the
> > graphics::text function.
> >
> > text (1:10, 1:10, LETTERS [1:10])
> >
> > If it's a different graphics system, then I don't know, but hopefully
> > someone else will help.
> >
> > On Thu, Mar 12, 2020 at 1:48 PM Ana Marija <[hidden email]>
> wrote:
> > >
> > > Thanks for getting back to me but I would need this text labels added
> in this particular instance
> > >
> > > On Wed, 11 Mar 2020 at 19:37, Abby Spurdle <[hidden email]>
> wrote:
> > >>
> > >> > and I would like to get the plot like the one in attach.
> > >> > Please advise,
> > >>
> > >> This is a bad idea.
> > >> Plots should be *easy* to interpret.
> > >>
> > >> Try to keep plots relatively simple, avoiding unnecessary details.
> > >> For nontrivial plots, use a caption to describe the main features of
> the plot.
> > >> (That's where your text should go).
> > >>
> > >> I note that you've asked a number of questions about QQ plots.
> > >> I'd recommend that you use QQ plots in a standard way, without
> > >> frequently trying to modify/customize them.
>
> ______________________________________________
> [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.
>


--
John Kane
Kingston ON Canada

        [[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: how do I add text lables on QQ plot

anikaM
I don’t need to use qqman package... if someone has any other solution
would be the most appreciated


On Wed, 11 Mar 2020 at 20:28, John Kane <[hidden email]> wrote:

> No idua how it works but the name suggests it in out of the Hadley
> universe and not basic graphics.
>
> On Wed, 11 Mar 2020 at 21:14, Abby Spurdle <[hidden email]> wrote:
>
>> One more thing, I can't find a CRAN package named "ggman".
>>
>> On Thu, Mar 12, 2020 at 1:59 PM Abby Spurdle <[hidden email]> wrote:
>> >
>> > Ok, then.
>> >
>> > What graphics system is the qq function using?
>> > Assuming that it's using the base graphics system, look at the
>> > graphics::text function.
>> >
>> > text (1:10, 1:10, LETTERS [1:10])
>> >
>> > If it's a different graphics system, then I don't know, but hopefully
>> > someone else will help.
>> >
>> > On Thu, Mar 12, 2020 at 1:48 PM Ana Marija <[hidden email]>
>> wrote:
>> > >
>> > > Thanks for getting back to me but I would need this text labels added
>> in this particular instance
>> > >
>> > > On Wed, 11 Mar 2020 at 19:37, Abby Spurdle <[hidden email]>
>> wrote:
>> > >>
>> > >> > and I would like to get the plot like the one in attach.
>> > >> > Please advise,
>> > >>
>> > >> This is a bad idea.
>> > >> Plots should be *easy* to interpret.
>> > >>
>> > >> Try to keep plots relatively simple, avoiding unnecessary details.
>> > >> For nontrivial plots, use a caption to describe the main features of
>> the plot.
>> > >> (That's where your text should go).
>> > >>
>> > >> I note that you've asked a number of questions about QQ plots.
>> > >> I'd recommend that you use QQ plots in a standard way, without
>> > >> frequently trying to modify/customize them.
>>
>> ______________________________________________
>
>
>> [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.
>>
>
>
> --
> John Kane
> Kingston ON Canada
>

        [[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: how do I add text lables on QQ plot

David Winsemius
In reply to this post by anikaM

On 3/10/20 9:51 PM, Ana Marija wrote:
> Hello,
>
> I am making QQ plot via:
>
> library(ggman)
> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17,
> col=fdr1_sorted$group, cex = 1, las = 1)


I think you may be confusing the audience. There is no qq function in
the ggman package. There is however a qq function in the qqman package.


Running the example in help page for qqman::qq and looking at the code
suggests this is a base plot function, so the text function will allow
you to put any particular string within the plot area:

library(qqman)

qq(gwasResults$P)
text( 2, 6, "arbitrary")  # puts text "arbitrary" at postion (x=2, y=6)

>
> data frames used look like this:
>
>> head(fdr1_sorted)

You should use `dput` to post reproducible data examples.

HTH;

David.

>                                         NAME             GS<br> follow
> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> 1:                 GO_DNA_PACKAGING_COMPLEX
> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> 0
> 2:                   GO_PROTEIN_DNA_COMPLEX
> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
>          0
> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
>         0
> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> -2.402153         0
> 6:                 GO_GRANULOCYTE_MIGRATION
> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> 0
>     FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> group FDR.q.val2
> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
>      2      1e-10
> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
>      2      1e-10
> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
>      4      1e-10
> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
>      4      1e-10
> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
>      4      1e-10
> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
>      4      1e-10
>
>> head(fdr2_sorted)
>                                         NAME             GS<br> follow
> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> 1:                 GO_DNA_PACKAGING_COMPLEX
> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> 0
> 2:                   GO_PROTEIN_DNA_COMPLEX
> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
>          0
> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
>         0
> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> -2.402153         0
> 6:                 GO_GRANULOCYTE_MIGRATION
> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> 0
>     FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> FDR.q.val2
> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
>       1e-10
> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
>       1e-10
> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
>       1e-10
> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
>       1e-10
> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
>       1e-10
> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
>       1e-10
>
> and I would like to get the plot like the one in attach.
>
> Please advise,
> Ana
>
> ______________________________________________
> [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: how do I add text lables on QQ plot

anikaM
HI David,

thank you for getting back to me.

Is there is a way for qq() to pick up text label names on its own or I
have to specify each one manually?
like in this example:
text( 2, 6, "arbitrary")

this is dput for

>a=head(fdr2_sorted)
> dput(a)
structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
"GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
"GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
"GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
"GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
"GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
"Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
    NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
    -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
    0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
    1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
list=10%, signal=47%",
    "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
    "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
    "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
    NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10,
    1e-10)), class = c("data.table", "data.frame"), row.names = c(NA,
-6L), .internal.selfref = <pointer: 0x10400bae0>)

> b=head(fdr1_sorted)
> dput(b)
structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
"GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
"GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
"GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
"GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
"GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
"Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
    NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
    -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
    0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
    1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
list=10%, signal=47%",
    "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
    "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
    "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
    NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10,
    1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table",
"data.frame"), row.names = c(NA, -6L), .internal.selfref = <pointer:
0x10400bae0>)

library(qqman)
qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
col=fdr1_sorted$group, cex = 0.8, las = 1)

Please advise

On Wed, Mar 11, 2020 at 11:21 PM David Winsemius <[hidden email]> wrote:

>
>
> On 3/10/20 9:51 PM, Ana Marija wrote:
> > Hello,
> >
> > I am making QQ plot via:
> >
> > library(ggman)
> > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17,
> > col=fdr1_sorted$group, cex = 1, las = 1)
>
>
> I think you may be confusing the audience. There is no qq function in
> the ggman package. There is however a qq function in the qqman package.
>
>
> Running the example in help page for qqman::qq and looking at the code
> suggests this is a base plot function, so the text function will allow
> you to put any particular string within the plot area:
>
> library(qqman)
>
> qq(gwasResults$P)
> text( 2, 6, "arbitrary")  # puts text "arbitrary" at postion (x=2, y=6)
>
> >
> > data frames used look like this:
> >
> >> head(fdr1_sorted)
>
> You should use `dput` to post reproducible data examples.
>
> HTH;
>
> David.
>
> >                                         NAME             GS<br> follow
> > link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> > 1:                 GO_DNA_PACKAGING_COMPLEX
> > GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> > 0
> > 2:                   GO_PROTEIN_DNA_COMPLEX
> > GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> > 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> > GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> >          0
> > 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> > GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> >         0
> > 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> > GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> > -2.402153         0
> > 6:                 GO_GRANULOCYTE_MIGRATION
> > GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> > 0
> >     FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> > group FDR.q.val2
> > 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> >      2      1e-10
> > 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> >      2      1e-10
> > 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> >      4      1e-10
> > 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> >      4      1e-10
> > 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> >      4      1e-10
> > 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> >      4      1e-10
> >
> >> head(fdr2_sorted)
> >                                         NAME             GS<br> follow
> > link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> > 1:                 GO_DNA_PACKAGING_COMPLEX
> > GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> > 0
> > 2:                   GO_PROTEIN_DNA_COMPLEX
> > GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> > 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> > GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> >          0
> > 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> > GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> >         0
> > 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> > GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> > -2.402153         0
> > 6:                 GO_GRANULOCYTE_MIGRATION
> > GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> > 0
> >     FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> > FDR.q.val2
> > 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> >       1e-10
> > 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> >       1e-10
> > 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> >       1e-10
> > 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> >       1e-10
> > 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> >       1e-10
> > 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> >       1e-10
> >
> > and I would like to get the plot like the one in attach.
> >
> > Please advise,
> > Ana
> >
> > ______________________________________________
> > [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: how do I add text lables on QQ plot

Michael Dewey-3
Dear Ana

You can specify the first three parameters to text() as vectors so it is
all done in one call. That may or may not answer your question.

Michael

On 12/03/2020 14:08, Ana Marija wrote:

> HI David,
>
> thank you for getting back to me.
>
> Is there is a way for qq() to pick up text label names on its own or I
> have to specify each one manually?
> like in this example:
> text( 2, 6, "arbitrary")
>
> this is dput for
>
>> a=head(fdr2_sorted)
>> dput(a)
> structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
>      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
>      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
>      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
>      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> list=10%, signal=47%",
>      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
>      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
>      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
>      NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10,
>      1e-10)), class = c("data.table", "data.frame"), row.names = c(NA,
> -6L), .internal.selfref = <pointer: 0x10400bae0>)
>
>> b=head(fdr1_sorted)
>> dput(b)
> structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
>      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
>      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
>      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
>      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> list=10%, signal=47%",
>      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
>      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
>      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
>      NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10,
>      1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table",
> "data.frame"), row.names = c(NA, -6L), .internal.selfref = <pointer:
> 0x10400bae0>)
>
> library(qqman)
> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
> col=fdr1_sorted$group, cex = 0.8, las = 1)
>
> Please advise
>
> On Wed, Mar 11, 2020 at 11:21 PM David Winsemius <[hidden email]> wrote:
>>
>>
>> On 3/10/20 9:51 PM, Ana Marija wrote:
>>> Hello,
>>>
>>> I am making QQ plot via:
>>>
>>> library(ggman)
>>> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17,
>>> col=fdr1_sorted$group, cex = 1, las = 1)
>>
>>
>> I think you may be confusing the audience. There is no qq function in
>> the ggman package. There is however a qq function in the qqman package.
>>
>>
>> Running the example in help page for qqman::qq and looking at the code
>> suggests this is a base plot function, so the text function will allow
>> you to put any particular string within the plot area:
>>
>> library(qqman)
>>
>> qq(gwasResults$P)
>> text( 2, 6, "arbitrary")  # puts text "arbitrary" at postion (x=2, y=6)
>>
>>>
>>> data frames used look like this:
>>>
>>>> head(fdr1_sorted)
>>
>> You should use `dput` to post reproducible data examples.
>>
>> HTH;
>>
>> David.
>>
>>>                                          NAME             GS<br> follow
>>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
>>> 1:                 GO_DNA_PACKAGING_COMPLEX
>>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
>>> 0
>>> 2:                   GO_PROTEIN_DNA_COMPLEX
>>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
>>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
>>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
>>>           0
>>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
>>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
>>>          0
>>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
>>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
>>> -2.402153         0
>>> 6:                 GO_GRANULOCYTE_MIGRATION
>>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
>>> 0
>>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
>>> group FDR.q.val2
>>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
>>>       2      1e-10
>>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
>>>       2      1e-10
>>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
>>>       4      1e-10
>>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
>>>       4      1e-10
>>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
>>>       4      1e-10
>>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
>>>       4      1e-10
>>>
>>>> head(fdr2_sorted)
>>>                                          NAME             GS<br> follow
>>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
>>> 1:                 GO_DNA_PACKAGING_COMPLEX
>>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
>>> 0
>>> 2:                   GO_PROTEIN_DNA_COMPLEX
>>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
>>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
>>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
>>>           0
>>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
>>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
>>>          0
>>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
>>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
>>> -2.402153         0
>>> 6:                 GO_GRANULOCYTE_MIGRATION
>>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
>>> 0
>>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
>>> FDR.q.val2
>>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
>>>        1e-10
>>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
>>>        1e-10
>>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
>>>        1e-10
>>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
>>>        1e-10
>>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
>>>        1e-10
>>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
>>>        1e-10
>>>
>>> and I would like to get the plot like the one in attach.
>>>
>>> Please advise,
>>> Ana
>>>
>>> ______________________________________________
>>> [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.
>

--
Michael
http://www.dewey.myzen.co.uk/home.html

______________________________________________
[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: how do I add text lables on QQ plot

anikaM
Hi Michael,

can you please send me a line of code showing how it would be done.

Thanks
Ana

On Thu, Mar 12, 2020 at 9:16 AM Michael Dewey <[hidden email]> wrote:

>
> Dear Ana
>
> You can specify the first three parameters to text() as vectors so it is
> all done in one call. That may or may not answer your question.
>
> Michael
>
> On 12/03/2020 14:08, Ana Marija wrote:
> > HI David,
> >
> > thank you for getting back to me.
> >
> > Is there is a way for qq() to pick up text label names on its own or I
> > have to specify each one manually?
> > like in this example:
> > text( 2, 6, "arbitrary")
> >
> > this is dput for
> >
> >> a=head(fdr2_sorted)
> >> dput(a)
> > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> > ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> > "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
> >      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
> >      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
> >      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
> >      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> > list=10%, signal=47%",
> >      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
> >      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
> >      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
> >      NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10,
> >      1e-10)), class = c("data.table", "data.frame"), row.names = c(NA,
> > -6L), .internal.selfref = <pointer: 0x10400bae0>)
> >
> >> b=head(fdr1_sorted)
> >> dput(b)
> > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> > ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> > "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
> >      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
> >      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
> >      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
> >      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> > list=10%, signal=47%",
> >      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
> >      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
> >      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
> >      NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10,
> >      1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table",
> > "data.frame"), row.names = c(NA, -6L), .internal.selfref = <pointer:
> > 0x10400bae0>)
> >
> > library(qqman)
> > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
> > col=fdr1_sorted$group, cex = 0.8, las = 1)
> >
> > Please advise
> >
> > On Wed, Mar 11, 2020 at 11:21 PM David Winsemius <[hidden email]> wrote:
> >>
> >>
> >> On 3/10/20 9:51 PM, Ana Marija wrote:
> >>> Hello,
> >>>
> >>> I am making QQ plot via:
> >>>
> >>> library(ggman)
> >>> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17,
> >>> col=fdr1_sorted$group, cex = 1, las = 1)
> >>
> >>
> >> I think you may be confusing the audience. There is no qq function in
> >> the ggman package. There is however a qq function in the qqman package.
> >>
> >>
> >> Running the example in help page for qqman::qq and looking at the code
> >> suggests this is a base plot function, so the text function will allow
> >> you to put any particular string within the plot area:
> >>
> >> library(qqman)
> >>
> >> qq(gwasResults$P)
> >> text( 2, 6, "arbitrary")  # puts text "arbitrary" at postion (x=2, y=6)
> >>
> >>>
> >>> data frames used look like this:
> >>>
> >>>> head(fdr1_sorted)
> >>
> >> You should use `dput` to post reproducible data examples.
> >>
> >> HTH;
> >>
> >> David.
> >>
> >>>                                          NAME             GS<br> follow
> >>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> >>> 1:                 GO_DNA_PACKAGING_COMPLEX
> >>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> >>> 0
> >>> 2:                   GO_PROTEIN_DNA_COMPLEX
> >>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> >>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> >>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> >>>           0
> >>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> >>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> >>>          0
> >>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> >>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> >>> -2.402153         0
> >>> 6:                 GO_GRANULOCYTE_MIGRATION
> >>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> >>> 0
> >>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> >>> group FDR.q.val2
> >>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> >>>       2      1e-10
> >>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> >>>       2      1e-10
> >>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> >>>       4      1e-10
> >>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> >>>       4      1e-10
> >>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> >>>       4      1e-10
> >>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> >>>       4      1e-10
> >>>
> >>>> head(fdr2_sorted)
> >>>                                          NAME             GS<br> follow
> >>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> >>> 1:                 GO_DNA_PACKAGING_COMPLEX
> >>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> >>> 0
> >>> 2:                   GO_PROTEIN_DNA_COMPLEX
> >>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> >>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> >>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> >>>           0
> >>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> >>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> >>>          0
> >>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> >>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> >>> -2.402153         0
> >>> 6:                 GO_GRANULOCYTE_MIGRATION
> >>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> >>> 0
> >>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> >>> FDR.q.val2
> >>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> >>>        1e-10
> >>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> >>>        1e-10
> >>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> >>>        1e-10
> >>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> >>>        1e-10
> >>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> >>>        1e-10
> >>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> >>>        1e-10
> >>>
> >>> and I would like to get the plot like the one in attach.
> >>>
> >>> Please advise,
> >>> Ana
> >>>
> >>> ______________________________________________
> >>> [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.
> >
>
> --
> Michael
> http://www.dewey.myzen.co.uk/home.html

______________________________________________
[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: how do I add text lables on QQ plot

anikaM
Also how would I add legend to this plot?

I searched qqman pages and there is no mention of that

qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
col=fdr1_sorted$group, cex = 0.8, las = 1)

On Thu, Mar 12, 2020 at 9:30 AM Ana Marija <[hidden email]> wrote:

>
> Hi Michael,
>
> can you please send me a line of code showing how it would be done.
>
> Thanks
> Ana
>
> On Thu, Mar 12, 2020 at 9:16 AM Michael Dewey <[hidden email]> wrote:
> >
> > Dear Ana
> >
> > You can specify the first three parameters to text() as vectors so it is
> > all done in one call. That may or may not answer your question.
> >
> > Michael
> >
> > On 12/03/2020 14:08, Ana Marija wrote:
> > > HI David,
> > >
> > > thank you for getting back to me.
> > >
> > > Is there is a way for qq() to pick up text label names on its own or I
> > > have to specify each one manually?
> > > like in this example:
> > > text( 2, 6, "arbitrary")
> > >
> > > this is dput for
> > >
> > >> a=head(fdr2_sorted)
> > >> dput(a)
> > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> > > ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> > > "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
> > >      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
> > >      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
> > >      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
> > >      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> > > list=10%, signal=47%",
> > >      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
> > >      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
> > >      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
> > >      NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10,
> > >      1e-10)), class = c("data.table", "data.frame"), row.names = c(NA,
> > > -6L), .internal.selfref = <pointer: 0x10400bae0>)
> > >
> > >> b=head(fdr1_sorted)
> > >> dput(b)
> > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> > > ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> > > "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
> > >      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
> > >      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
> > >      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
> > >      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> > > list=10%, signal=47%",
> > >      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
> > >      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
> > >      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
> > >      NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10,
> > >      1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table",
> > > "data.frame"), row.names = c(NA, -6L), .internal.selfref = <pointer:
> > > 0x10400bae0>)
> > >
> > > library(qqman)
> > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
> > > col=fdr1_sorted$group, cex = 0.8, las = 1)
> > >
> > > Please advise
> > >
> > > On Wed, Mar 11, 2020 at 11:21 PM David Winsemius <[hidden email]> wrote:
> > >>
> > >>
> > >> On 3/10/20 9:51 PM, Ana Marija wrote:
> > >>> Hello,
> > >>>
> > >>> I am making QQ plot via:
> > >>>
> > >>> library(ggman)
> > >>> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17,
> > >>> col=fdr1_sorted$group, cex = 1, las = 1)
> > >>
> > >>
> > >> I think you may be confusing the audience. There is no qq function in
> > >> the ggman package. There is however a qq function in the qqman package.
> > >>
> > >>
> > >> Running the example in help page for qqman::qq and looking at the code
> > >> suggests this is a base plot function, so the text function will allow
> > >> you to put any particular string within the plot area:
> > >>
> > >> library(qqman)
> > >>
> > >> qq(gwasResults$P)
> > >> text( 2, 6, "arbitrary")  # puts text "arbitrary" at postion (x=2, y=6)
> > >>
> > >>>
> > >>> data frames used look like this:
> > >>>
> > >>>> head(fdr1_sorted)
> > >>
> > >> You should use `dput` to post reproducible data examples.
> > >>
> > >> HTH;
> > >>
> > >> David.
> > >>
> > >>>                                          NAME             GS<br> follow
> > >>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> > >>> 1:                 GO_DNA_PACKAGING_COMPLEX
> > >>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> > >>> 0
> > >>> 2:                   GO_PROTEIN_DNA_COMPLEX
> > >>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> > >>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> > >>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> > >>>           0
> > >>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> > >>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> > >>>          0
> > >>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> > >>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> > >>> -2.402153         0
> > >>> 6:                 GO_GRANULOCYTE_MIGRATION
> > >>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> > >>> 0
> > >>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> > >>> group FDR.q.val2
> > >>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> > >>>       2      1e-10
> > >>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> > >>>       2      1e-10
> > >>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> > >>>       4      1e-10
> > >>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> > >>>       4      1e-10
> > >>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> > >>>       4      1e-10
> > >>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> > >>>       4      1e-10
> > >>>
> > >>>> head(fdr2_sorted)
> > >>>                                          NAME             GS<br> follow
> > >>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> > >>> 1:                 GO_DNA_PACKAGING_COMPLEX
> > >>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> > >>> 0
> > >>> 2:                   GO_PROTEIN_DNA_COMPLEX
> > >>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> > >>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> > >>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> > >>>           0
> > >>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> > >>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> > >>>          0
> > >>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> > >>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> > >>> -2.402153         0
> > >>> 6:                 GO_GRANULOCYTE_MIGRATION
> > >>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> > >>> 0
> > >>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> > >>> FDR.q.val2
> > >>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> > >>>        1e-10
> > >>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> > >>>        1e-10
> > >>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> > >>>        1e-10
> > >>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> > >>>        1e-10
> > >>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> > >>>        1e-10
> > >>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> > >>>        1e-10
> > >>>
> > >>> and I would like to get the plot like the one in attach.
> > >>>
> > >>> Please advise,
> > >>> Ana
> > >>>
> > >>> ______________________________________________
> > >>> [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.
> > >
> >
> > --
> > Michael
> > http://www.dewey.myzen.co.uk/home.html

______________________________________________
[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: how do I add text lables on QQ plot

anikaM
I could make legend via this:
qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
col=fdr1_sorted$group, cex = 0.8, las = 1)
legend('topleft', legend = c('up-regulated', 'down-regulated'), fill =
c('red', 'blue'),bty="o")

but this gives me squares in legend. How do I write this code in order
to have circles in the legend?

On Thu, Mar 12, 2020 at 11:04 AM Ana Marija <[hidden email]> wrote:

>
> Also how would I add legend to this plot?
>
> I searched qqman pages and there is no mention of that
>
> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
> col=fdr1_sorted$group, cex = 0.8, las = 1)
>
> On Thu, Mar 12, 2020 at 9:30 AM Ana Marija <[hidden email]> wrote:
> >
> > Hi Michael,
> >
> > can you please send me a line of code showing how it would be done.
> >
> > Thanks
> > Ana
> >
> > On Thu, Mar 12, 2020 at 9:16 AM Michael Dewey <[hidden email]> wrote:
> > >
> > > Dear Ana
> > >
> > > You can specify the first three parameters to text() as vectors so it is
> > > all done in one call. That may or may not answer your question.
> > >
> > > Michael
> > >
> > > On 12/03/2020 14:08, Ana Marija wrote:
> > > > HI David,
> > > >
> > > > thank you for getting back to me.
> > > >
> > > > Is there is a way for qq() to pick up text label names on its own or I
> > > > have to specify each one manually?
> > > > like in this example:
> > > > text( 2, 6, "arbitrary")
> > > >
> > > > this is dput for
> > > >
> > > >> a=head(fdr2_sorted)
> > > >> dput(a)
> > > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> > > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> > > > ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> > > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> > > > "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> > > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> > > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> > > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> > > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
> > > >      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
> > > >      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
> > > >      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
> > > >      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> > > > list=10%, signal=47%",
> > > >      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
> > > >      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
> > > >      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
> > > >      NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10,
> > > >      1e-10)), class = c("data.table", "data.frame"), row.names = c(NA,
> > > > -6L), .internal.selfref = <pointer: 0x10400bae0>)
> > > >
> > > >> b=head(fdr1_sorted)
> > > >> dput(b)
> > > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> > > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> > > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> > > > ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> > > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> > > > "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> > > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> > > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> > > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> > > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
> > > >      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
> > > >      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
> > > >      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
> > > >      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> > > > list=10%, signal=47%",
> > > >      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
> > > >      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
> > > >      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
> > > >      NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10,
> > > >      1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table",
> > > > "data.frame"), row.names = c(NA, -6L), .internal.selfref = <pointer:
> > > > 0x10400bae0>)
> > > >
> > > > library(qqman)
> > > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
> > > > col=fdr1_sorted$group, cex = 0.8, las = 1)
> > > >
> > > > Please advise
> > > >
> > > > On Wed, Mar 11, 2020 at 11:21 PM David Winsemius <[hidden email]> wrote:
> > > >>
> > > >>
> > > >> On 3/10/20 9:51 PM, Ana Marija wrote:
> > > >>> Hello,
> > > >>>
> > > >>> I am making QQ plot via:
> > > >>>
> > > >>> library(ggman)
> > > >>> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17,
> > > >>> col=fdr1_sorted$group, cex = 1, las = 1)
> > > >>
> > > >>
> > > >> I think you may be confusing the audience. There is no qq function in
> > > >> the ggman package. There is however a qq function in the qqman package.
> > > >>
> > > >>
> > > >> Running the example in help page for qqman::qq and looking at the code
> > > >> suggests this is a base plot function, so the text function will allow
> > > >> you to put any particular string within the plot area:
> > > >>
> > > >> library(qqman)
> > > >>
> > > >> qq(gwasResults$P)
> > > >> text( 2, 6, "arbitrary")  # puts text "arbitrary" at postion (x=2, y=6)
> > > >>
> > > >>>
> > > >>> data frames used look like this:
> > > >>>
> > > >>>> head(fdr1_sorted)
> > > >>
> > > >> You should use `dput` to post reproducible data examples.
> > > >>
> > > >> HTH;
> > > >>
> > > >> David.
> > > >>
> > > >>>                                          NAME             GS<br> follow
> > > >>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> > > >>> 1:                 GO_DNA_PACKAGING_COMPLEX
> > > >>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> > > >>> 0
> > > >>> 2:                   GO_PROTEIN_DNA_COMPLEX
> > > >>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> > > >>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> > > >>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> > > >>>           0
> > > >>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> > > >>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> > > >>>          0
> > > >>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> > > >>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> > > >>> -2.402153         0
> > > >>> 6:                 GO_GRANULOCYTE_MIGRATION
> > > >>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> > > >>> 0
> > > >>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> > > >>> group FDR.q.val2
> > > >>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> > > >>>       2      1e-10
> > > >>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> > > >>>       2      1e-10
> > > >>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> > > >>>       4      1e-10
> > > >>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> > > >>>       4      1e-10
> > > >>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> > > >>>       4      1e-10
> > > >>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> > > >>>       4      1e-10
> > > >>>
> > > >>>> head(fdr2_sorted)
> > > >>>                                          NAME             GS<br> follow
> > > >>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> > > >>> 1:                 GO_DNA_PACKAGING_COMPLEX
> > > >>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> > > >>> 0
> > > >>> 2:                   GO_PROTEIN_DNA_COMPLEX
> > > >>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> > > >>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> > > >>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> > > >>>           0
> > > >>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> > > >>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> > > >>>          0
> > > >>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> > > >>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> > > >>> -2.402153         0
> > > >>> 6:                 GO_GRANULOCYTE_MIGRATION
> > > >>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> > > >>> 0
> > > >>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> > > >>> FDR.q.val2
> > > >>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> > > >>>        1e-10
> > > >>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> > > >>>        1e-10
> > > >>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> > > >>>        1e-10
> > > >>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> > > >>>        1e-10
> > > >>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> > > >>>        1e-10
> > > >>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> > > >>>        1e-10
> > > >>>
> > > >>> and I would like to get the plot like the one in attach.
> > > >>>
> > > >>> Please advise,
> > > >>> Ana
> > > >>>
> > > >>> ______________________________________________
> > > >>> [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.
> > > >
> > >
> > > --
> > > Michael
> > > http://www.dewey.myzen.co.uk/home.html

______________________________________________
[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: how do I add text lables on QQ plot

Abby Spurdle
In reply to this post by anikaM
Hi Ana,

I've already given you an example of using the text function with vectors.

I note that this thread contains a lot of duplication.
I'd recommend people read the whole thread before posting.


On Fri, Mar 13, 2020 at 3:42 AM Ana Marija <[hidden email]> wrote:

>
> Hi Michael,
>
> can you please send me a line of code showing how it would be done.
>
> Thanks
> Ana
>
> On Thu, Mar 12, 2020 at 9:16 AM Michael Dewey <[hidden email]> wrote:
> >
> > Dear Ana
> >
> > You can specify the first three parameters to text() as vectors so it is
> > all done in one call. That may or may not answer your question.
> >
> > Michael
> >
> > On 12/03/2020 14:08, Ana Marija wrote:
> > > HI David,
> > >
> > > thank you for getting back to me.
> > >
> > > Is there is a way for qq() to pick up text label names on its own or I
> > > have to specify each one manually?
> > > like in this example:
> > > text( 2, 6, "arbitrary")
> > >
> > > this is dput for
> > >
> > >> a=head(fdr2_sorted)
> > >> dput(a)
> > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> > > ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> > > "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
> > >      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
> > >      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
> > >      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
> > >      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> > > list=10%, signal=47%",
> > >      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
> > >      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
> > >      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
> > >      NA, NA), FDR.q.val2 = c(1e-10, 1e-10, 1e-10, 1e-10, 1e-10,
> > >      1e-10)), class = c("data.table", "data.frame"), row.names = c(NA,
> > > -6L), .internal.selfref = <pointer: 0x10400bae0>)
> > >
> > >> b=head(fdr1_sorted)
> > >> dput(b)
> > > structure(list(NAME = c("GO_DNA_PACKAGING_COMPLEX", "GO_PROTEIN_DNA_COMPLEX",
> > > "GO_RESPONSE_TO_TYPE_I_INTERFERON", "GO_RESPONSE_TO_INTERFERON_GAMMA",
> > > "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA", "GO_GRANULOCYTE_MIGRATION"
> > > ), `GS<br> follow link to MSigDB` = c("GO_DNA_PACKAGING_COMPLEX",
> > > "GO_PROTEIN_DNA_COMPLEX", "GO_RESPONSE_TO_TYPE_I_INTERFERON",
> > > "GO_RESPONSE_TO_INTERFERON_GAMMA", "GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA",
> > > "GO_GRANULOCYTE_MIGRATION"), `GS DETAILS` = c("Details ...",
> > > "Details ...", "Details ...", "Details ...", "Details ...", "Details ..."
> > > ), SIZE = c(77L, 132L, 52L, 101L, 85L, 43L), ES = c(0.6757226,
> > > 0.59581786, -0.7521569, -0.63704145, -0.6571892, -0.7332099),
> > >      NES = c(2.466745, 2.3465202, -2.5331483, -2.4204733, -2.4021535,
> > >      -2.3989832), `NOM p-val` = c(0, 0, 0, 0, 0, 0), `FDR q-val` = c(0,
> > >      0, 0, 0, 0, 0), `FWER p-val` = c(0, 0, 0, 0, 0, 0), `RANK AT MAX` = c(1111L,
> > >      1516L, 1427L, 1819L, 1216L, 491L), `LEADING EDGE` = c("tags=43%,
> > > list=10%, signal=47%",
> > >      "tags=39%, list=13%, signal=45%", "tags=54%, list=12%, signal=61%",
> > >      "tags=45%, list=16%, signal=52%", "tags=38%, list=11%, signal=42%",
> > >      "tags=28%, list=4%, signal=29%"), V12 = c(NA, NA, NA, NA,
> > >      NA, NA), group = c(2, 2, 4, 4, 4, 4), FDR.q.val2 = c(1e-10,
> > >      1e-10, 1e-10, 1e-10, 1e-10, 1e-10)), class = c("data.table",
> > > "data.frame"), row.names = c(NA, -6L), .internal.selfref = <pointer:
> > > 0x10400bae0>)
> > >
> > > library(qqman)
> > > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
> > > col=fdr1_sorted$group, cex = 0.8, las = 1)
> > >
> > > Please advise
> > >
> > > On Wed, Mar 11, 2020 at 11:21 PM David Winsemius <[hidden email]> wrote:
> > >>
> > >>
> > >> On 3/10/20 9:51 PM, Ana Marija wrote:
> > >>> Hello,
> > >>>
> > >>> I am making QQ plot via:
> > >>>
> > >>> library(ggman)
> > >>> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 17,
> > >>> col=fdr1_sorted$group, cex = 1, las = 1)
> > >>
> > >>
> > >> I think you may be confusing the audience. There is no qq function in
> > >> the ggman package. There is however a qq function in the qqman package.
> > >>
> > >>
> > >> Running the example in help page for qqman::qq and looking at the code
> > >> suggests this is a base plot function, so the text function will allow
> > >> you to put any particular string within the plot area:
> > >>
> > >> library(qqman)
> > >>
> > >> qq(gwasResults$P)
> > >> text( 2, 6, "arbitrary")  # puts text "arbitrary" at postion (x=2, y=6)
> > >>
> > >>>
> > >>> data frames used look like this:
> > >>>
> > >>>> head(fdr1_sorted)
> > >>
> > >> You should use `dput` to post reproducible data examples.
> > >>
> > >> HTH;
> > >>
> > >> David.
> > >>
> > >>>                                          NAME             GS<br> follow
> > >>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> > >>> 1:                 GO_DNA_PACKAGING_COMPLEX
> > >>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> > >>> 0
> > >>> 2:                   GO_PROTEIN_DNA_COMPLEX
> > >>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> > >>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> > >>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> > >>>           0
> > >>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> > >>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> > >>>          0
> > >>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> > >>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> > >>> -2.402153         0
> > >>> 6:                 GO_GRANULOCYTE_MIGRATION
> > >>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> > >>> 0
> > >>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> > >>> group FDR.q.val2
> > >>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> > >>>       2      1e-10
> > >>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> > >>>       2      1e-10
> > >>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> > >>>       4      1e-10
> > >>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> > >>>       4      1e-10
> > >>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> > >>>       4      1e-10
> > >>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> > >>>       4      1e-10
> > >>>
> > >>>> head(fdr2_sorted)
> > >>>                                          NAME             GS<br> follow
> > >>> link to MSigDB  GS DETAILS SIZE         ES       NES NOM p-val
> > >>> 1:                 GO_DNA_PACKAGING_COMPLEX
> > >>> GO_DNA_PACKAGING_COMPLEX Details ...   77  0.6757226  2.466745
> > >>> 0
> > >>> 2:                   GO_PROTEIN_DNA_COMPLEX
> > >>> GO_PROTEIN_DNA_COMPLEX Details ...  132  0.5958179  2.346520         0
> > >>> 3:         GO_RESPONSE_TO_TYPE_I_INTERFERON
> > >>> GO_RESPONSE_TO_TYPE_I_INTERFERON Details ...   52 -0.7521569 -2.533148
> > >>>           0
> > >>> 4:          GO_RESPONSE_TO_INTERFERON_GAMMA
> > >>> GO_RESPONSE_TO_INTERFERON_GAMMA Details ...  101 -0.6370415 -2.420473
> > >>>          0
> > >>> 5: GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA
> > >>> GO_CELLULAR_RESPONSE_TO_INTERFERON_GAMMA Details ...   85 -0.6571892
> > >>> -2.402153         0
> > >>> 6:                 GO_GRANULOCYTE_MIGRATION
> > >>> GO_GRANULOCYTE_MIGRATION Details ...   43 -0.7332099 -2.398983
> > >>> 0
> > >>>      FDR q-val FWER p-val RANK AT MAX                   LEADING EDGE V12
> > >>> FDR.q.val2
> > >>> 1:         0          0        1111 tags=43%, list=10%, signal=47%  NA
> > >>>        1e-10
> > >>> 2:         0          0        1516 tags=39%, list=13%, signal=45%  NA
> > >>>        1e-10
> > >>> 3:         0          0        1427 tags=54%, list=12%, signal=61%  NA
> > >>>        1e-10
> > >>> 4:         0          0        1819 tags=45%, list=16%, signal=52%  NA
> > >>>        1e-10
> > >>> 5:         0          0        1216 tags=38%, list=11%, signal=42%  NA
> > >>>        1e-10
> > >>> 6:         0          0         491  tags=28%, list=4%, signal=29%  NA
> > >>>        1e-10
> > >>>
> > >>> and I would like to get the plot like the one in attach.
> > >>>
> > >>> Please advise,
> > >>> Ana
> > >>>
> > >>> ______________________________________________
> > >>> [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.
> > >
> >
> > --
> > Michael
> > http://www.dewey.myzen.co.uk/home.html
>
> ______________________________________________
> [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: how do I add text lables on QQ plot

Abby Spurdle
In reply to this post by anikaM
The plotting character is determined by the pch argument.
i.e. You need to specify the pch argument in the legend call.

Here's the R code to preview the first 20 plotting characters:

> plot (1:20, rep (0, 20), pch=1:20, ylim = c (-5, 5) )
> text (1:20, rep (1, 20), 1:20)

Empty circles, have a pch value of 1.
Solid circles, have a pch value of 16.
In general, to set the color, use the col argument.

So, you could add the following to your legend call:

> ..., pch=16, col = c ("red", "blue"), ...

And remove the fill argument.



On 3/13/20, Ana Marija <[hidden email]> wrote:

> I could make legend via this:
> qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
> col=fdr1_sorted$group, cex = 0.8, las = 1)
> legend('topleft', legend = c('up-regulated', 'down-regulated'), fill =
> c('red', 'blue'),bty="o")
>
> but this gives me squares in legend. How do I write this code in order
> to have circles in the legend?
>
> On Thu, Mar 12, 2020 at 11:04 AM Ana Marija <[hidden email]>
> wrote:
>>
>> Also how would I add legend to this plot?
>>
>> I searched qqman pages and there is no mention of that

______________________________________________
[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: how do I add text lables on QQ plot

anikaM
Thank you!

On Thu, Mar 12, 2020 at 12:47 PM Abby Spurdle <[hidden email]> wrote:

>
> The plotting character is determined by the pch argument.
> i.e. You need to specify the pch argument in the legend call.
>
> Here's the R code to preview the first 20 plotting characters:
>
> > plot (1:20, rep (0, 20), pch=1:20, ylim = c (-5, 5) )
> > text (1:20, rep (1, 20), 1:20)
>
> Empty circles, have a pch value of 1.
> Solid circles, have a pch value of 16.
> In general, to set the color, use the col argument.
>
> So, you could add the following to your legend call:
>
> > ..., pch=16, col = c ("red", "blue"), ...
>
> And remove the fill argument.
>
>
>
> On 3/13/20, Ana Marija <[hidden email]> wrote:
> > I could make legend via this:
> > qq(fdr2_sorted$FDR.q.val2, main = "RG_All", pch = 16,
> > col=fdr1_sorted$group, cex = 0.8, las = 1)
> > legend('topleft', legend = c('up-regulated', 'down-regulated'), fill =
> > c('red', 'blue'),bty="o")
> >
> > but this gives me squares in legend. How do I write this code in order
> > to have circles in the legend?
> >
> > On Thu, Mar 12, 2020 at 11:04 AM Ana Marija <[hidden email]>
> > wrote:
> >>
> >> Also how would I add legend to this plot?
> >>
> >> I searched qqman pages and there is no mention of that

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