Re: how to create density plot in R with p value

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

Re: how to create density plot in R with p value

anikaM
so I transformed my data from the previous email to look like this:

> head(tot)
     dat                      type
1 -3.962 inter.individual.variance
2 -4.301 inter.individual.variance
3 -1.690 inter.individual.variance
4 -0.375 inter.individual.variance
5  1.816 inter.individual.variance
6  0.138 inter.individual.variance
> tail(tot)
        dat                      type
31177 -4.09 intra.individual.variance
31178 -4.64 intra.individual.variance
31179 -5.57 intra.individual.variance
31180 -2.96 intra.individual.variance
31181 -4.43 intra.individual.variance
31182 -3.60 intra.individual.variance

then I can make plot using this:

densityplot(~dat,data=tot,
       groups=type,
       par.settings = list(superpose.line = list(col = c("blue","red"))),
       xlab="log2 (variance)",
       plot.points=FALSE,
       auto.key=TRUE)

and calculate my p value with t test, say it is 0.005

But how to add that p value in between distribution of the curves?

Thanks
Ana

On Tue, Feb 11, 2020 at 12:54 PM Ana Marija <[hidden email]> wrote:

>
> Hi,
>
> I have data like this:
>
> > head(a)
>                    X   geneID inter.individual.variance
> intra.individual.variance F.value  p.value     CV
> 1 3iUZ.47hLFki49VR4o   MLLT10                    0.0642
>    0.01395    4.60 1.00e-05 0.0222
> 2 fEn1QlU0MCVe9GeR64 C1orf123                    0.0507
>    0.00671    7.57 1.00e-08 0.0172
> 3 ud_tTlU5LtB478JxIk    FSD1L                    0.3100
>    0.02682   11.56 1.00e-11 0.0639
> 4 3KV3OJIIRuJ5KJ6VkI  TXNDC11                    0.7710
>    0.02813   27.41 9.99e-19 0.0688
> 5 o_rupcEAKnQqnoh6ec   CYB5R2                    3.5209
>    0.03391  103.83 9.99e-31 0.1357
> 6 Nk_t6ULcQ7VDNChBRU     GBP1                    1.1005
>    0.09522   11.56 9.98e-12 0.0773
>
> I would like to create density plot, like the attached between
> "inter.individual.variance" and "intra.individual.variance" and have p
> value between those two curves.
>
> 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.
Reply | Threaded
Open this post in threaded view
|

Re: how to create density plot in R with p value

John Kane-3
Please supply sample data in dput() format See ?dput.

You might find these links helpful.

 http://adv-r.had.co.nz/Reproducibility.html

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example



On Tue, 11 Feb 2020 at 15:07, Ana Marija <[hidden email]>
wrote:

> so I transformed my data from the previous email to look like this:
>
> > head(tot)
>      dat                      type
> 1 -3.962 inter.individual.variance
> 2 -4.301 inter.individual.variance
> 3 -1.690 inter.individual.variance
> 4 -0.375 inter.individual.variance
> 5  1.816 inter.individual.variance
> 6  0.138 inter.individual.variance
> > tail(tot)
>         dat                      type
> 31177 -4.09 intra.individual.variance
> 31178 -4.64 intra.individual.variance
> 31179 -5.57 intra.individual.variance
> 31180 -2.96 intra.individual.variance
> 31181 -4.43 intra.individual.variance
> 31182 -3.60 intra.individual.variance
>
> then I can make plot using this:
>
> densityplot(~dat,data=tot,
>        groups=type,
>        par.settings = list(superpose.line = list(col = c("blue","red"))),
>        xlab="log2 (variance)",
>        plot.points=FALSE,
>        auto.key=TRUE)
>
> and calculate my p value with t test, say it is 0.005
>
> But how to add that p value in between distribution of the curves?
>
> Thanks
> Ana
>
> On Tue, Feb 11, 2020 at 12:54 PM Ana Marija <[hidden email]>
> wrote:
> >
> > Hi,
> >
> > I have data like this:
> >
> > > head(a)
> >                    X   geneID inter.individual.variance
> > intra.individual.variance F.value  p.value     CV
> > 1 3iUZ.47hLFki49VR4o   MLLT10                    0.0642
> >    0.01395    4.60 1.00e-05 0.0222
> > 2 fEn1QlU0MCVe9GeR64 C1orf123                    0.0507
> >    0.00671    7.57 1.00e-08 0.0172
> > 3 ud_tTlU5LtB478JxIk    FSD1L                    0.3100
> >    0.02682   11.56 1.00e-11 0.0639
> > 4 3KV3OJIIRuJ5KJ6VkI  TXNDC11                    0.7710
> >    0.02813   27.41 9.99e-19 0.0688
> > 5 o_rupcEAKnQqnoh6ec   CYB5R2                    3.5209
> >    0.03391  103.83 9.99e-31 0.1357
> > 6 Nk_t6ULcQ7VDNChBRU     GBP1                    1.1005
> >    0.09522   11.56 9.98e-12 0.0773
> >
> > I would like to create density plot, like the attached between
> > "inter.individual.variance" and "intra.individual.variance" and have p
> > value between those two curves.
> >
> > 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.
>


--
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 to create density plot in R with p value

Jim Lemon-4
In reply to this post by anikaM
Hi Ana,
Your image didn't make it through (as usual). Try PNG or PDF format.

Assumptions
1) You want to plot two lines using the _paired_ values of inter- and
intra-individual variance.
2) The cases are in the same order in your data
3) You want to identify the two lines
4) You want to place text with some p-value between the lines

This is really (and suspiciously) simple. Here's a start:

tot<-read.table(text="dat type
 -3.962 inter.individual.variance
 -4.301 inter.individual.variance
 -1.690 inter.individual.variance
 -0.375 inter.individual.variance
  1.816 inter.individual.variance
  0.138 inter.individual.variance
 -4.09 intra.individual.variance
 -4.64 intra.individual.variance
 -5.57 intra.individual.variance
 -2.96 intra.individual.variance
 -4.43 intra.individual.variance
 -3.60 intra.individual.variance",
 header=TRUE)
# get the numeric values of the factor 'type'
tot$ntype<-as.numeric(tot$type)
plot(tot$dat[tot$ntype==1],type="l",col="green",ylim=range(tot$dat))
lines(tot$dat[tot$ntype==2],col="blue")
text(5,-1.5,"p = 0.005")
legend(1,1,c("Inter-individual variance","Intra-individual variance"),
 lty=1,col=c("green","blue"))

Jim

On Wed, Feb 12, 2020 at 7:07 AM Ana Marija <[hidden email]> wrote:

>
> so I transformed my data from the previous email to look like this:
>
> > head(tot)
>      dat                      type
> 1 -3.962 inter.individual.variance
> 2 -4.301 inter.individual.variance
> 3 -1.690 inter.individual.variance
> 4 -0.375 inter.individual.variance
> 5  1.816 inter.individual.variance
> 6  0.138 inter.individual.variance
> > tail(tot)
>         dat                      type
> 31177 -4.09 intra.individual.variance
> 31178 -4.64 intra.individual.variance
> 31179 -5.57 intra.individual.variance
> 31180 -2.96 intra.individual.variance
> 31181 -4.43 intra.individual.variance
> 31182 -3.60 intra.individual.variance
>
> then I can make plot using this:
>
> densityplot(~dat,data=tot,
>        groups=type,
>        par.settings = list(superpose.line = list(col = c("blue","red"))),
>        xlab="log2 (variance)",
>        plot.points=FALSE,
>        auto.key=TRUE)
>
> and calculate my p value with t test, say it is 0.005
>
> But how to add that p value in between distribution of the curves?
>
> Thanks
> Ana
>
> On Tue, Feb 11, 2020 at 12:54 PM Ana Marija <[hidden email]> wrote:
> >
> > Hi,
> >
> > I have data like this:
> >
> > > head(a)
> >                    X   geneID inter.individual.variance
> > intra.individual.variance F.value  p.value     CV
> > 1 3iUZ.47hLFki49VR4o   MLLT10                    0.0642
> >    0.01395    4.60 1.00e-05 0.0222
> > 2 fEn1QlU0MCVe9GeR64 C1orf123                    0.0507
> >    0.00671    7.57 1.00e-08 0.0172
> > 3 ud_tTlU5LtB478JxIk    FSD1L                    0.3100
> >    0.02682   11.56 1.00e-11 0.0639
> > 4 3KV3OJIIRuJ5KJ6VkI  TXNDC11                    0.7710
> >    0.02813   27.41 9.99e-19 0.0688
> > 5 o_rupcEAKnQqnoh6ec   CYB5R2                    3.5209
> >    0.03391  103.83 9.99e-31 0.1357
> > 6 Nk_t6ULcQ7VDNChBRU     GBP1                    1.1005
> >    0.09522   11.56 9.98e-12 0.0773
> >
> > I would like to create density plot, like the attached between
> > "inter.individual.variance" and "intra.individual.variance" and have p
> > value between those two curves.
> >
> > 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 to create density plot in R with p value

anikaM
Hi Jim


I tried your code and it didn't show me density curves.

However I was able to do teh plot myself via:

densityplot(~dat,data=tot,
       groups=type,
       par.settings = list(superpose.line = list(col = c("blue","red"))),
       xlab="log2 (variance)",
       plot.points=FALSE,
       auto.key=TRUE)


and it is attached. The only thing I need to do is to make a line in
between peaks of the curves and put the star above that line. Not a p
value but just a star symbol.

Please advise,
Thanks
Ana

On Tue, Feb 11, 2020 at 3:23 PM Jim Lemon <[hidden email]> wrote:

>
> Hi Ana,
> Your image didn't make it through (as usual). Try PNG or PDF format.
>
> Assumptions
> 1) You want to plot two lines using the _paired_ values of inter- and
> intra-individual variance.
> 2) The cases are in the same order in your data
> 3) You want to identify the two lines
> 4) You want to place text with some p-value between the lines
>
> This is really (and suspiciously) simple. Here's a start:
>
> tot<-read.table(text="dat type
>  -3.962 inter.individual.variance
>  -4.301 inter.individual.variance
>  -1.690 inter.individual.variance
>  -0.375 inter.individual.variance
>   1.816 inter.individual.variance
>   0.138 inter.individual.variance
>  -4.09 intra.individual.variance
>  -4.64 intra.individual.variance
>  -5.57 intra.individual.variance
>  -2.96 intra.individual.variance
>  -4.43 intra.individual.variance
>  -3.60 intra.individual.variance",
>  header=TRUE)
> # get the numeric values of the factor 'type'
> tot$ntype<-as.numeric(tot$type)
> plot(tot$dat[tot$ntype==1],type="l",col="green",ylim=range(tot$dat))
> lines(tot$dat[tot$ntype==2],col="blue")
> text(5,-1.5,"p = 0.005")
> legend(1,1,c("Inter-individual variance","Intra-individual variance"),
>  lty=1,col=c("green","blue"))
>
> Jim
>
> On Wed, Feb 12, 2020 at 7:07 AM Ana Marija <[hidden email]> wrote:
> >
> > so I transformed my data from the previous email to look like this:
> >
> > > head(tot)
> >      dat                      type
> > 1 -3.962 inter.individual.variance
> > 2 -4.301 inter.individual.variance
> > 3 -1.690 inter.individual.variance
> > 4 -0.375 inter.individual.variance
> > 5  1.816 inter.individual.variance
> > 6  0.138 inter.individual.variance
> > > tail(tot)
> >         dat                      type
> > 31177 -4.09 intra.individual.variance
> > 31178 -4.64 intra.individual.variance
> > 31179 -5.57 intra.individual.variance
> > 31180 -2.96 intra.individual.variance
> > 31181 -4.43 intra.individual.variance
> > 31182 -3.60 intra.individual.variance
> >
> > then I can make plot using this:
> >
> > densityplot(~dat,data=tot,
> >        groups=type,
> >        par.settings = list(superpose.line = list(col = c("blue","red"))),
> >        xlab="log2 (variance)",
> >        plot.points=FALSE,
> >        auto.key=TRUE)
> >
> > and calculate my p value with t test, say it is 0.005
> >
> > But how to add that p value in between distribution of the curves?
> >
> > Thanks
> > Ana
> >
> > On Tue, Feb 11, 2020 at 12:54 PM Ana Marija <[hidden email]> wrote:
> > >
> > > Hi,
> > >
> > > I have data like this:
> > >
> > > > head(a)
> > >                    X   geneID inter.individual.variance
> > > intra.individual.variance F.value  p.value     CV
> > > 1 3iUZ.47hLFki49VR4o   MLLT10                    0.0642
> > >    0.01395    4.60 1.00e-05 0.0222
> > > 2 fEn1QlU0MCVe9GeR64 C1orf123                    0.0507
> > >    0.00671    7.57 1.00e-08 0.0172
> > > 3 ud_tTlU5LtB478JxIk    FSD1L                    0.3100
> > >    0.02682   11.56 1.00e-11 0.0639
> > > 4 3KV3OJIIRuJ5KJ6VkI  TXNDC11                    0.7710
> > >    0.02813   27.41 9.99e-19 0.0688
> > > 5 o_rupcEAKnQqnoh6ec   CYB5R2                    3.5209
> > >    0.03391  103.83 9.99e-31 0.1357
> > > 6 Nk_t6ULcQ7VDNChBRU     GBP1                    1.1005
> > >    0.09522   11.56 9.98e-12 0.0773
> > >
> > > I would like to create density plot, like the attached between
> > > "inter.individual.variance" and "intra.individual.variance" and have p
> > > value between those two curves.
> > >
> > > 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.

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

Re: how to create density plot in R with p value

anikaM
Hi Jim


I tried your code and it didn't show me density curves.

However I was able to do teh plot myself via:

densityplot(~dat,data=tot,
       groups=type,
       par.settings = list(superpose.line = list(col = c("blue","red"))),
       xlab="log2 (variance)",
       plot.points=FALSE,
       auto.key=TRUE)


and it is attached. The only thing I need to do is to make a line in
between peaks of the curves and put the star above that line. Not a p
value but just a star symbol.

Please advise,
Thanks

On Tue, Feb 11, 2020 at 3:46 PM Ana Marija <[hidden email]> wrote:

>
> Hi Jim
>
>
> I tried your code and it didn't show me density curves.
>
> However I was able to do teh plot myself via:
>
> densityplot(~dat,data=tot,
>        groups=type,
>        par.settings = list(superpose.line = list(col = c("blue","red"))),
>        xlab="log2 (variance)",
>        plot.points=FALSE,
>        auto.key=TRUE)
>
>
> and it is attached. The only thing I need to do is to make a line in
> between peaks of the curves and put the star above that line. Not a p
> value but just a star symbol.
>
> Please advise,
> Thanks
> Ana
>
> On Tue, Feb 11, 2020 at 3:23 PM Jim Lemon <[hidden email]> wrote:
> >
> > Hi Ana,
> > Your image didn't make it through (as usual). Try PNG or PDF format.
> >
> > Assumptions
> > 1) You want to plot two lines using the _paired_ values of inter- and
> > intra-individual variance.
> > 2) The cases are in the same order in your data
> > 3) You want to identify the two lines
> > 4) You want to place text with some p-value between the lines
> >
> > This is really (and suspiciously) simple. Here's a start:
> >
> > tot<-read.table(text="dat type
> >  -3.962 inter.individual.variance
> >  -4.301 inter.individual.variance
> >  -1.690 inter.individual.variance
> >  -0.375 inter.individual.variance
> >   1.816 inter.individual.variance
> >   0.138 inter.individual.variance
> >  -4.09 intra.individual.variance
> >  -4.64 intra.individual.variance
> >  -5.57 intra.individual.variance
> >  -2.96 intra.individual.variance
> >  -4.43 intra.individual.variance
> >  -3.60 intra.individual.variance",
> >  header=TRUE)
> > # get the numeric values of the factor 'type'
> > tot$ntype<-as.numeric(tot$type)
> > plot(tot$dat[tot$ntype==1],type="l",col="green",ylim=range(tot$dat))
> > lines(tot$dat[tot$ntype==2],col="blue")
> > text(5,-1.5,"p = 0.005")
> > legend(1,1,c("Inter-individual variance","Intra-individual variance"),
> >  lty=1,col=c("green","blue"))
> >
> > Jim
> >
> > On Wed, Feb 12, 2020 at 7:07 AM Ana Marija <[hidden email]> wrote:
> > >
> > > so I transformed my data from the previous email to look like this:
> > >
> > > > head(tot)
> > >      dat                      type
> > > 1 -3.962 inter.individual.variance
> > > 2 -4.301 inter.individual.variance
> > > 3 -1.690 inter.individual.variance
> > > 4 -0.375 inter.individual.variance
> > > 5  1.816 inter.individual.variance
> > > 6  0.138 inter.individual.variance
> > > > tail(tot)
> > >         dat                      type
> > > 31177 -4.09 intra.individual.variance
> > > 31178 -4.64 intra.individual.variance
> > > 31179 -5.57 intra.individual.variance
> > > 31180 -2.96 intra.individual.variance
> > > 31181 -4.43 intra.individual.variance
> > > 31182 -3.60 intra.individual.variance
> > >
> > > then I can make plot using this:
> > >
> > > densityplot(~dat,data=tot,
> > >        groups=type,
> > >        par.settings = list(superpose.line = list(col = c("blue","red"))),
> > >        xlab="log2 (variance)",
> > >        plot.points=FALSE,
> > >        auto.key=TRUE)
> > >
> > > and calculate my p value with t test, say it is 0.005
> > >
> > > But how to add that p value in between distribution of the curves?
> > >
> > > Thanks
> > > Ana
> > >
> > > On Tue, Feb 11, 2020 at 12:54 PM Ana Marija <[hidden email]> wrote:
> > > >
> > > > Hi,
> > > >
> > > > I have data like this:
> > > >
> > > > > head(a)
> > > >                    X   geneID inter.individual.variance
> > > > intra.individual.variance F.value  p.value     CV
> > > > 1 3iUZ.47hLFki49VR4o   MLLT10                    0.0642
> > > >    0.01395    4.60 1.00e-05 0.0222
> > > > 2 fEn1QlU0MCVe9GeR64 C1orf123                    0.0507
> > > >    0.00671    7.57 1.00e-08 0.0172
> > > > 3 ud_tTlU5LtB478JxIk    FSD1L                    0.3100
> > > >    0.02682   11.56 1.00e-11 0.0639
> > > > 4 3KV3OJIIRuJ5KJ6VkI  TXNDC11                    0.7710
> > > >    0.02813   27.41 9.99e-19 0.0688
> > > > 5 o_rupcEAKnQqnoh6ec   CYB5R2                    3.5209
> > > >    0.03391  103.83 9.99e-31 0.1357
> > > > 6 Nk_t6ULcQ7VDNChBRU     GBP1                    1.1005
> > > >    0.09522   11.56 9.98e-12 0.0773
> > > >
> > > > I would like to create density plot, like the attached between
> > > > "inter.individual.variance" and "intra.individual.variance" and have p
> > > > value between those two curves.
> > > >
> > > > 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.

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

Re: how to create density plot in R with p value

Jim Lemon-4
Hi Ana,
Okay, it's the lattice package. Try this:

panel.abline(v=-4)
panel.text(-3.9,0.35,"*")

As I don't have your data I can't provide a complete example.

Jim

On Wed, Feb 12, 2020 at 8:50 AM Ana Marija <[hidden email]> wrote:

>
> Hi Jim
>
>
> I tried your code and it didn't show me density curves.
>
> However I was able to do teh plot myself via:
>
> densityplot(~dat,data=tot,
>        groups=type,
>        par.settings = list(superpose.line = list(col = c("blue","red"))),
>        xlab="log2 (variance)",
>        plot.points=FALSE,
>        auto.key=TRUE)
>
>
> and it is attached. The only thing I need to do is to make a line in
> between peaks of the curves and put the star above that line. Not a p
> value but just a star symbol.
>
> Please advise,
> Thanks
>
> On Tue, Feb 11, 2020 at 3:46 PM Ana Marija <[hidden email]> wrote:
> >
> > Hi Jim
> >
> >
> > I tried your code and it didn't show me density curves.
> >
> > However I was able to do teh plot myself via:
> >
> > densityplot(~dat,data=tot,
> >        groups=type,
> >        par.settings = list(superpose.line = list(col = c("blue","red"))),
> >        xlab="log2 (variance)",
> >        plot.points=FALSE,
> >        auto.key=TRUE)
> >
> >
> > and it is attached. The only thing I need to do is to make a line in
> > between peaks of the curves and put the star above that line. Not a p
> > value but just a star symbol.
> >
> > Please advise,
> > Thanks
> > Ana
> >
> > On Tue, Feb 11, 2020 at 3:23 PM Jim Lemon <[hidden email]> wrote:
> > >
> > > Hi Ana,
> > > Your image didn't make it through (as usual). Try PNG or PDF format.
> > >
> > > Assumptions
> > > 1) You want to plot two lines using the _paired_ values of inter- and
> > > intra-individual variance.
> > > 2) The cases are in the same order in your data
> > > 3) You want to identify the two lines
> > > 4) You want to place text with some p-value between the lines
> > >
> > > This is really (and suspiciously) simple. Here's a start:
> > >
> > > tot<-read.table(text="dat type
> > >  -3.962 inter.individual.variance
> > >  -4.301 inter.individual.variance
> > >  -1.690 inter.individual.variance
> > >  -0.375 inter.individual.variance
> > >   1.816 inter.individual.variance
> > >   0.138 inter.individual.variance
> > >  -4.09 intra.individual.variance
> > >  -4.64 intra.individual.variance
> > >  -5.57 intra.individual.variance
> > >  -2.96 intra.individual.variance
> > >  -4.43 intra.individual.variance
> > >  -3.60 intra.individual.variance",
> > >  header=TRUE)
> > > # get the numeric values of the factor 'type'
> > > tot$ntype<-as.numeric(tot$type)
> > > plot(tot$dat[tot$ntype==1],type="l",col="green",ylim=range(tot$dat))
> > > lines(tot$dat[tot$ntype==2],col="blue")
> > > text(5,-1.5,"p = 0.005")
> > > legend(1,1,c("Inter-individual variance","Intra-individual variance"),
> > >  lty=1,col=c("green","blue"))
> > >
> > > Jim
> > >
> > > On Wed, Feb 12, 2020 at 7:07 AM Ana Marija <[hidden email]> wrote:
> > > >
> > > > so I transformed my data from the previous email to look like this:
> > > >
> > > > > head(tot)
> > > >      dat                      type
> > > > 1 -3.962 inter.individual.variance
> > > > 2 -4.301 inter.individual.variance
> > > > 3 -1.690 inter.individual.variance
> > > > 4 -0.375 inter.individual.variance
> > > > 5  1.816 inter.individual.variance
> > > > 6  0.138 inter.individual.variance
> > > > > tail(tot)
> > > >         dat                      type
> > > > 31177 -4.09 intra.individual.variance
> > > > 31178 -4.64 intra.individual.variance
> > > > 31179 -5.57 intra.individual.variance
> > > > 31180 -2.96 intra.individual.variance
> > > > 31181 -4.43 intra.individual.variance
> > > > 31182 -3.60 intra.individual.variance
> > > >
> > > > then I can make plot using this:
> > > >
> > > > densityplot(~dat,data=tot,
> > > >        groups=type,
> > > >        par.settings = list(superpose.line = list(col = c("blue","red"))),
> > > >        xlab="log2 (variance)",
> > > >        plot.points=FALSE,
> > > >        auto.key=TRUE)
> > > >
> > > > and calculate my p value with t test, say it is 0.005
> > > >
> > > > But how to add that p value in between distribution of the curves?
> > > >
> > > > Thanks
> > > > Ana
> > > >
> > > > On Tue, Feb 11, 2020 at 12:54 PM Ana Marija <[hidden email]> wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I have data like this:
> > > > >
> > > > > > head(a)
> > > > >                    X   geneID inter.individual.variance
> > > > > intra.individual.variance F.value  p.value     CV
> > > > > 1 3iUZ.47hLFki49VR4o   MLLT10                    0.0642
> > > > >    0.01395    4.60 1.00e-05 0.0222
> > > > > 2 fEn1QlU0MCVe9GeR64 C1orf123                    0.0507
> > > > >    0.00671    7.57 1.00e-08 0.0172
> > > > > 3 ud_tTlU5LtB478JxIk    FSD1L                    0.3100
> > > > >    0.02682   11.56 1.00e-11 0.0639
> > > > > 4 3KV3OJIIRuJ5KJ6VkI  TXNDC11                    0.7710
> > > > >    0.02813   27.41 9.99e-19 0.0688
> > > > > 5 o_rupcEAKnQqnoh6ec   CYB5R2                    3.5209
> > > > >    0.03391  103.83 9.99e-31 0.1357
> > > > > 6 Nk_t6ULcQ7VDNChBRU     GBP1                    1.1005
> > > > >    0.09522   11.56 9.98e-12 0.0773
> > > > >
> > > > > I would like to create density plot, like the attached between
> > > > > "inter.individual.variance" and "intra.individual.variance" and have p
> > > > > value between those two curves.
> > > > >
> > > > > 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 to create density plot in R with p value

Bert Gunter-2
I assume you mean:

densityplot(~dat,data=tot,
       groups=type,
       panel = function(...){
          panel.densityplot(...)
          panel.abline(v= -4)
          panel.text(-3.9, 0.35, "*")
       },
       par.settings = list(superpose.line = list(col = c("blue","red"))),
       xlab="log2 (variance)",
       plot.points=FALSE,
       auto.key=TRUE)

**warning**: in the absence of data, untested.


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Feb 11, 2020 at 3:14 PM Jim Lemon <[hidden email]> wrote:

> Hi Ana,
> Okay, it's the lattice package. Try this:
>
> panel.abline(v=-4)
> panel.text(-3.9,0.35,"*")
>
> As I don't have your data I can't provide a complete example.
>
> Jim
>
> On Wed, Feb 12, 2020 at 8:50 AM Ana Marija <[hidden email]>
> wrote:
> >
> > Hi Jim
> >
> >
> > I tried your code and it didn't show me density curves.
> >
> > However I was able to do teh plot myself via:
> >
> > densityplot(~dat,data=tot,
> >        groups=type,
> >        par.settings = list(superpose.line = list(col = c("blue","red"))),
> >        xlab="log2 (variance)",
> >        plot.points=FALSE,
> >        auto.key=TRUE)
> >
> >
> > and it is attached. The only thing I need to do is to make a line in
> > between peaks of the curves and put the star above that line. Not a p
> > value but just a star symbol.
> >
> > Please advise,
> > Thanks
> >
> > On Tue, Feb 11, 2020 at 3:46 PM Ana Marija <[hidden email]>
> wrote:
> > >
> > > Hi Jim
> > >
> > >
> > > I tried your code and it didn't show me density curves.
> > >
> > > However I was able to do teh plot myself via:
> > >
> > > densityplot(~dat,data=tot,
> > >        groups=type,
> > >        par.settings = list(superpose.line = list(col =
> c("blue","red"))),
> > >        xlab="log2 (variance)",
> > >        plot.points=FALSE,
> > >        auto.key=TRUE)
> > >
> > >
> > > and it is attached. The only thing I need to do is to make a line in
> > > between peaks of the curves and put the star above that line. Not a p
> > > value but just a star symbol.
> > >
> > > Please advise,
> > > Thanks
> > > Ana
> > >
> > > On Tue, Feb 11, 2020 at 3:23 PM Jim Lemon <[hidden email]>
> wrote:
> > > >
> > > > Hi Ana,
> > > > Your image didn't make it through (as usual). Try PNG or PDF format.
> > > >
> > > > Assumptions
> > > > 1) You want to plot two lines using the _paired_ values of inter- and
> > > > intra-individual variance.
> > > > 2) The cases are in the same order in your data
> > > > 3) You want to identify the two lines
> > > > 4) You want to place text with some p-value between the lines
> > > >
> > > > This is really (and suspiciously) simple. Here's a start:
> > > >
> > > > tot<-read.table(text="dat type
> > > >  -3.962 inter.individual.variance
> > > >  -4.301 inter.individual.variance
> > > >  -1.690 inter.individual.variance
> > > >  -0.375 inter.individual.variance
> > > >   1.816 inter.individual.variance
> > > >   0.138 inter.individual.variance
> > > >  -4.09 intra.individual.variance
> > > >  -4.64 intra.individual.variance
> > > >  -5.57 intra.individual.variance
> > > >  -2.96 intra.individual.variance
> > > >  -4.43 intra.individual.variance
> > > >  -3.60 intra.individual.variance",
> > > >  header=TRUE)
> > > > # get the numeric values of the factor 'type'
> > > > tot$ntype<-as.numeric(tot$type)
> > > > plot(tot$dat[tot$ntype==1],type="l",col="green",ylim=range(tot$dat))
> > > > lines(tot$dat[tot$ntype==2],col="blue")
> > > > text(5,-1.5,"p = 0.005")
> > > > legend(1,1,c("Inter-individual variance","Intra-individual
> variance"),
> > > >  lty=1,col=c("green","blue"))
> > > >
> > > > Jim
> > > >
> > > > On Wed, Feb 12, 2020 at 7:07 AM Ana Marija <
> [hidden email]> wrote:
> > > > >
> > > > > so I transformed my data from the previous email to look like this:
> > > > >
> > > > > > head(tot)
> > > > >      dat                      type
> > > > > 1 -3.962 inter.individual.variance
> > > > > 2 -4.301 inter.individual.variance
> > > > > 3 -1.690 inter.individual.variance
> > > > > 4 -0.375 inter.individual.variance
> > > > > 5  1.816 inter.individual.variance
> > > > > 6  0.138 inter.individual.variance
> > > > > > tail(tot)
> > > > >         dat                      type
> > > > > 31177 -4.09 intra.individual.variance
> > > > > 31178 -4.64 intra.individual.variance
> > > > > 31179 -5.57 intra.individual.variance
> > > > > 31180 -2.96 intra.individual.variance
> > > > > 31181 -4.43 intra.individual.variance
> > > > > 31182 -3.60 intra.individual.variance
> > > > >
> > > > > then I can make plot using this:
> > > > >
> > > > > densityplot(~dat,data=tot,
> > > > >        groups=type,
> > > > >        par.settings = list(superpose.line = list(col =
> c("blue","red"))),
> > > > >        xlab="log2 (variance)",
> > > > >        plot.points=FALSE,
> > > > >        auto.key=TRUE)
> > > > >
> > > > > and calculate my p value with t test, say it is 0.005
> > > > >
> > > > > But how to add that p value in between distribution of the curves?
> > > > >
> > > > > Thanks
> > > > > Ana
> > > > >
> > > > > On Tue, Feb 11, 2020 at 12:54 PM Ana Marija <
> [hidden email]> wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I have data like this:
> > > > > >
> > > > > > > head(a)
> > > > > >                    X   geneID inter.individual.variance
> > > > > > intra.individual.variance F.value  p.value     CV
> > > > > > 1 3iUZ.47hLFki49VR4o   MLLT10                    0.0642
> > > > > >    0.01395    4.60 1.00e-05 0.0222
> > > > > > 2 fEn1QlU0MCVe9GeR64 C1orf123                    0.0507
> > > > > >    0.00671    7.57 1.00e-08 0.0172
> > > > > > 3 ud_tTlU5LtB478JxIk    FSD1L                    0.3100
> > > > > >    0.02682   11.56 1.00e-11 0.0639
> > > > > > 4 3KV3OJIIRuJ5KJ6VkI  TXNDC11                    0.7710
> > > > > >    0.02813   27.41 9.99e-19 0.0688
> > > > > > 5 o_rupcEAKnQqnoh6ec   CYB5R2                    3.5209
> > > > > >    0.03391  103.83 9.99e-31 0.1357
> > > > > > 6 Nk_t6ULcQ7VDNChBRU     GBP1                    1.1005
> > > > > >    0.09522   11.56 9.98e-12 0.0773
> > > > > >
> > > > > > I would like to create density plot, like the attached between
> > > > > > "inter.individual.variance" and "intra.individual.variance" and
> have p
> > > > > > value between those two curves.
> > > > > >
> > > > > > 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.
>

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