Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Jim Lemon
Hi Adrian,
Perhaps what you want is this:

ajdat<-structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
"CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
)))
library(plotrix)
twoord.plot(0.8:6.8,ajdat[2,],1.2:7.2,ajdat[1,],
 main="Gene expression by chromosome loss/gain",
 lylim=c(-2.2,10),lytickpos=-2:2,
 xtickpos=1:7,xticklab=colnames(ajdat),
 ylab="Chromosome loss/gain",rylab="GN",
 type="bar",lcol=2,rcol=3,halfwidth=0.2)

Jim


On Thu, Oct 13, 2016 at 3:20 AM, Adrian Johnson
 wrote:
> Dear group,
> I have been struggling to barplot two different measurements from one
> subject. These two measures differ in range.  I want to plot row 1
> axis on left side and row 2 values on right side.
>
> For a given column I want to plot GN and CN next to each other.
>
> my dput code is below
> :
>
> structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
> 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
> "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
> )))
>
>
> As you can see:
>DC5 DC8 DC14 DC18 DC19 DC20 DC23
> GN 112 579  131 2234 2892  528  582
> CN   0   112102
>
> GN values are range from 100 - 3000
> while CN are always -2 or -1 or 0 or 1 or 2
>
> Also I cannot log GN values and plot because a difference in 100 units
> also matters in my experiment.
>
> Any help would be greatly appreciated.
>
> Thanks
> Adrian
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
As Dr.Murdoch suggested, transformation of row 2 is important to make
sense in graphical depiction.
Thanks to all.


On Wed, Oct 12, 2016 at 4:25 PM, Adrian Johnson
<oriolebaltim...@gmail.com> wrote:
> Hello Dr. Carlson,
> thanks for the tip. It is exactly what I am looking for.
>
> I see the trick lies in
> axis(4, c(-1000, -500, 0, 500, 1000), c(-2, -1, 0, 1, 2))
>
> Would you please help understand why two different vectors of ranges
> are defined and yet I see only vector with -2,-1,0,1,2 is visible.
>
> Thanks a lot.
> Adrian
>
>
>
>
>
> On Wed, Oct 12, 2016 at 3:46 PM, David L Carlson <dcarl...@tamu.edu> wrote:
>> Are you looking for something like this?
>>
>> Assuming your data is d:
>>
>>> d[2, ] <- d[2, ]*500
>>> oldp <- par(mar=c(4.1, 4.1, 4.1, 4.1))
>>> barplot(d, ylim=c(-1000, 3000), beside=TRUE, axes=FALSE)
>>> axis(2, c(0, 1000, 2000, 3000))
>>> axis(4, c(-1000, -500, 0, 500, 1000), c(-2, -1, 0, 1, 2))
>>> mtext("GN", 2, 2)
>>> mtext("CN", 4, 2, at=0)
>>> par(oldp)
>>
>>
>>
>> -
>> David L Carlson
>> Department of Anthropology
>> Texas A University
>> College Station, TX 77840-4352
>>
>>
>>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Adams, Jean
>> Sent: Wednesday, October 12, 2016 12:44 PM
>> To: Adrian Johnson
>> Cc: r-help
>> Subject: Re: [R] barplot beside=TRUE - values differ on scales
>>
>> Adrian,
>>
>> Very interesting.
>>
>> What do you think of using colors to indicate the five possible loss/gain
>> levels?
>> For example:
>>
>> a <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
>>   528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
>>   "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
>>   )))
>>
>> loss.gain <- c(-2, -1, 0, 1, 2)
>> colorz <- c("blue", "lightblue", "gray", "orange", "red")
>> barplot(a["GN", ], col=colorz[match(a["CN", ], loss.gain)])
>>
>> Jean
>>
>> On Wed, Oct 12, 2016 at 11:55 AM, Adrian Johnson <oriolebaltim...@gmail.com>
>> wrote:
>>
>>> Hi Adams,
>>> The story I am trying to show visually relationship between GN and CN
>>> for every column. Each column represents a patient. In each patient, a
>>> particular chromosome region (CN) is either lost (-2 or -1) or gained
>>> (1 or 2). Typically if loss (one copy loss - as humans have pair of
>>> chromosome) or homozygous (two copies loss) theoretically indicate
>>> decrease in number of copies of gene located in that region of
>>> chromosome. The number of copies of a gene located in that chromosomal
>>> regions are indicated by GN.
>>> through this barplot, I intend to show that in 7 cases (columns) if a
>>> relationship exist by plotting GN and CN next to each other.  If I log
>>> values in GN, I am loosing the minor differences between cases in GN.
>>> hope I could convince/explain.
>>> thanks
>>> adrian
>>>
>>> On Wed, Oct 12, 2016 at 12:36 PM, Adams, Jean <jvad...@usgs.gov> wrote:
>>> > Adrian,
>>> >
>>> > What story are you trying to tell?  Or what question are you trying to
>>> > answer by visualizing these data?  How is a bar plot of these numbers
>>> going
>>> > to help?  I'm just wondering if perhaps a different visualization might
>>> make
>>> > more sense, for example, a scatter plot of GN vs. CN.
>>> >
>>> > m <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
>>> >   528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
>>> >   "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
>>> >   )))
>>> > plot(m["GN", ], m["CN", ])
>>> >
>>> > Jean
>>> >
>>> >
>>> > On Wed, Oct 12, 2016 at 11:20 AM, Adrian Johnson <
>>> oriolebaltim...@gmail.com>
>>> > wrote:
>>> >>
>>> >> Dear group,
>>> >> I have been struggling to barplot two different measurements from one
>>> >> subject. T

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
Hello Dr. Carlson,
thanks for the tip. It is exactly what I am looking for.

I see the trick lies in
axis(4, c(-1000, -500, 0, 500, 1000), c(-2, -1, 0, 1, 2))

Would you please help understand why two different vectors of ranges
are defined and yet I see only vector with -2,-1,0,1,2 is visible.

Thanks a lot.
Adrian





On Wed, Oct 12, 2016 at 3:46 PM, David L Carlson <dcarl...@tamu.edu> wrote:
> Are you looking for something like this?
>
> Assuming your data is d:
>
>> d[2, ] <- d[2, ]*500
>> oldp <- par(mar=c(4.1, 4.1, 4.1, 4.1))
>> barplot(d, ylim=c(-1000, 3000), beside=TRUE, axes=FALSE)
>> axis(2, c(0, 1000, 2000, 3000))
>> axis(4, c(-1000, -500, 0, 500, 1000), c(-2, -1, 0, 1, 2))
>> mtext("GN", 2, 2)
>> mtext("CN", 4, 2, at=0)
>> par(oldp)
>
>
>
> -
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77840-4352
>
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Adams, Jean
> Sent: Wednesday, October 12, 2016 12:44 PM
> To: Adrian Johnson
> Cc: r-help
> Subject: Re: [R] barplot beside=TRUE - values differ on scales
>
> Adrian,
>
> Very interesting.
>
> What do you think of using colors to indicate the five possible loss/gain
> levels?
> For example:
>
> a <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
>   528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
>   "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
>   )))
>
> loss.gain <- c(-2, -1, 0, 1, 2)
> colorz <- c("blue", "lightblue", "gray", "orange", "red")
> barplot(a["GN", ], col=colorz[match(a["CN", ], loss.gain)])
>
> Jean
>
> On Wed, Oct 12, 2016 at 11:55 AM, Adrian Johnson <oriolebaltim...@gmail.com>
> wrote:
>
>> Hi Adams,
>> The story I am trying to show visually relationship between GN and CN
>> for every column. Each column represents a patient. In each patient, a
>> particular chromosome region (CN) is either lost (-2 or -1) or gained
>> (1 or 2). Typically if loss (one copy loss - as humans have pair of
>> chromosome) or homozygous (two copies loss) theoretically indicate
>> decrease in number of copies of gene located in that region of
>> chromosome. The number of copies of a gene located in that chromosomal
>> regions are indicated by GN.
>> through this barplot, I intend to show that in 7 cases (columns) if a
>> relationship exist by plotting GN and CN next to each other.  If I log
>> values in GN, I am loosing the minor differences between cases in GN.
>> hope I could convince/explain.
>> thanks
>> adrian
>>
>> On Wed, Oct 12, 2016 at 12:36 PM, Adams, Jean <jvad...@usgs.gov> wrote:
>> > Adrian,
>> >
>> > What story are you trying to tell?  Or what question are you trying to
>> > answer by visualizing these data?  How is a bar plot of these numbers
>> going
>> > to help?  I'm just wondering if perhaps a different visualization might
>> make
>> > more sense, for example, a scatter plot of GN vs. CN.
>> >
>> > m <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
>> >   528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
>> >   "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
>> >   )))
>> > plot(m["GN", ], m["CN", ])
>> >
>> > Jean
>> >
>> >
>> > On Wed, Oct 12, 2016 at 11:20 AM, Adrian Johnson <
>> oriolebaltim...@gmail.com>
>> > wrote:
>> >>
>> >> Dear group,
>> >> I have been struggling to barplot two different measurements from one
>> >> subject. These two measures differ in range.  I want to plot row 1
>> >> axis on left side and row 2 values on right side.
>> >>
>> >> For a given column I want to plot GN and CN next to each other.
>> >>
>> >> my dput code is below
>> >> :
>> >>
>> >> structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
>> >> 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
>> >> "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
>&g

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread David L Carlson
Are you looking for something like this?

Assuming your data is d:

> d[2, ] <- d[2, ]*500
> oldp <- par(mar=c(4.1, 4.1, 4.1, 4.1))
> barplot(d, ylim=c(-1000, 3000), beside=TRUE, axes=FALSE)
> axis(2, c(0, 1000, 2000, 3000))
> axis(4, c(-1000, -500, 0, 500, 1000), c(-2, -1, 0, 1, 2))
> mtext("GN", 2, 2)
> mtext("CN", 4, 2, at=0)
> par(oldp)



-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Adams, Jean
Sent: Wednesday, October 12, 2016 12:44 PM
To: Adrian Johnson
Cc: r-help
Subject: Re: [R] barplot beside=TRUE - values differ on scales

Adrian,

Very interesting.

What do you think of using colors to indicate the five possible loss/gain
levels?
For example:

a <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
  528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
  "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
  )))

loss.gain <- c(-2, -1, 0, 1, 2)
colorz <- c("blue", "lightblue", "gray", "orange", "red")
barplot(a["GN", ], col=colorz[match(a["CN", ], loss.gain)])

Jean

On Wed, Oct 12, 2016 at 11:55 AM, Adrian Johnson <oriolebaltim...@gmail.com>
wrote:

> Hi Adams,
> The story I am trying to show visually relationship between GN and CN
> for every column. Each column represents a patient. In each patient, a
> particular chromosome region (CN) is either lost (-2 or -1) or gained
> (1 or 2). Typically if loss (one copy loss - as humans have pair of
> chromosome) or homozygous (two copies loss) theoretically indicate
> decrease in number of copies of gene located in that region of
> chromosome. The number of copies of a gene located in that chromosomal
> regions are indicated by GN.
> through this barplot, I intend to show that in 7 cases (columns) if a
> relationship exist by plotting GN and CN next to each other.  If I log
> values in GN, I am loosing the minor differences between cases in GN.
> hope I could convince/explain.
> thanks
> adrian
>
> On Wed, Oct 12, 2016 at 12:36 PM, Adams, Jean <jvad...@usgs.gov> wrote:
> > Adrian,
> >
> > What story are you trying to tell?  Or what question are you trying to
> > answer by visualizing these data?  How is a bar plot of these numbers
> going
> > to help?  I'm just wondering if perhaps a different visualization might
> make
> > more sense, for example, a scatter plot of GN vs. CN.
> >
> > m <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
> >   528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
> >   "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
> >   )))
> > plot(m["GN", ], m["CN", ])
> >
> > Jean
> >
> >
> > On Wed, Oct 12, 2016 at 11:20 AM, Adrian Johnson <
> oriolebaltim...@gmail.com>
> > wrote:
> >>
> >> Dear group,
> >> I have been struggling to barplot two different measurements from one
> >> subject. These two measures differ in range.  I want to plot row 1
> >> axis on left side and row 2 values on right side.
> >>
> >> For a given column I want to plot GN and CN next to each other.
> >>
> >> my dput code is below
> >> :
> >>
> >> structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
> >> 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
> >> "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
> >> )))
> >>
> >>
> >> As you can see:
> >>DC5 DC8 DC14 DC18 DC19 DC20 DC23
> >> GN 112 579  131 2234 2892  528  582
> >> CN   0   112102
> >>
> >> GN values are range from 100 - 3000
> >> while CN are always -2 or -1 or 0 or 1 or 2
> >>
> >> Also I cannot log GN values and plot because a difference in 100 units
> >> also matters in my experiment.
> >>
> >> Any help would be greatly appreciated.
> >>
> >> Thanks
> >> Adrian
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adams, Jean
Adrian,

Very interesting.

What do you think of using colors to indicate the five possible loss/gain
levels?
For example:

a <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
  528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
  "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
  )))

loss.gain <- c(-2, -1, 0, 1, 2)
colorz <- c("blue", "lightblue", "gray", "orange", "red")
barplot(a["GN", ], col=colorz[match(a["CN", ], loss.gain)])

Jean

On Wed, Oct 12, 2016 at 11:55 AM, Adrian Johnson 
wrote:

> Hi Adams,
> The story I am trying to show visually relationship between GN and CN
> for every column. Each column represents a patient. In each patient, a
> particular chromosome region (CN) is either lost (-2 or -1) or gained
> (1 or 2). Typically if loss (one copy loss - as humans have pair of
> chromosome) or homozygous (two copies loss) theoretically indicate
> decrease in number of copies of gene located in that region of
> chromosome. The number of copies of a gene located in that chromosomal
> regions are indicated by GN.
> through this barplot, I intend to show that in 7 cases (columns) if a
> relationship exist by plotting GN and CN next to each other.  If I log
> values in GN, I am loosing the minor differences between cases in GN.
> hope I could convince/explain.
> thanks
> adrian
>
> On Wed, Oct 12, 2016 at 12:36 PM, Adams, Jean  wrote:
> > Adrian,
> >
> > What story are you trying to tell?  Or what question are you trying to
> > answer by visualizing these data?  How is a bar plot of these numbers
> going
> > to help?  I'm just wondering if perhaps a different visualization might
> make
> > more sense, for example, a scatter plot of GN vs. CN.
> >
> > m <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
> >   528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
> >   "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
> >   )))
> > plot(m["GN", ], m["CN", ])
> >
> > Jean
> >
> >
> > On Wed, Oct 12, 2016 at 11:20 AM, Adrian Johnson <
> oriolebaltim...@gmail.com>
> > wrote:
> >>
> >> Dear group,
> >> I have been struggling to barplot two different measurements from one
> >> subject. These two measures differ in range.  I want to plot row 1
> >> axis on left side and row 2 values on right side.
> >>
> >> For a given column I want to plot GN and CN next to each other.
> >>
> >> my dput code is below
> >> :
> >>
> >> structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
> >> 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
> >> "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
> >> )))
> >>
> >>
> >> As you can see:
> >>DC5 DC8 DC14 DC18 DC19 DC20 DC23
> >> GN 112 579  131 2234 2892  528  582
> >> CN   0   112102
> >>
> >> GN values are range from 100 - 3000
> >> while CN are always -2 or -1 or 0 or 1 or 2
> >>
> >> Also I cannot log GN values and plot because a difference in 100 units
> >> also matters in my experiment.
> >>
> >> Any help would be greatly appreciated.
> >>
> >> Thanks
> >> Adrian
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Duncan Murdoch

On 12/10/2016 12:59 PM, Adrian Johnson wrote:

Thanks Duncan.
I am sorry I cannot scale second row (d[2,]).
I was looking for a way to plot d[2,] values next to d[1,]  with a
right side axis=4  on right side. -2,-1,0,1,2


That doesn't really make graphical sense, but you can use any 
transformation you like, not just a rescaling.  If you want -2 for the 
2nd row to be the same as 0 on the first row, just work out the 
transformation that achieves that, and use it.


Duncan Murdoch

thanks
Adrian

On Wed, Oct 12, 2016 at 12:42 PM, Duncan Murdoch
 wrote:
> On 12/10/2016 12:20 PM, Adrian Johnson wrote:
>>
>> Dear group,
>> I have been struggling to barplot two different measurements from one
>> subject. These two measures differ in range.  I want to plot row 1
>> axis on left side and row 2 values on right side.
>>
>> For a given column I want to plot GN and CN next to each other.
>>
>> my dput code is below
>> :
>>
>> structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
>> 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
>> "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
>> )))
>>
>>
>> As you can see:
>> DC5 DC8 DC14 DC18 DC19 DC20 DC23
>> GN 112 579  131 2234 2892  528  582
>> CN   0   112102
>>
>> GN values are range from 100 - 3000
>> while CN are always -2 or -1 or 0 or 1 or 2
>>
>> Also I cannot log GN values and plot because a difference in 100 units
>> also matters in my experiment.
>>
>> Any help would be greatly appreciated.
>
>
> I would simply rescale one row and add a second axis.  For example, if d
> holds your matrix:
>
> scale <- max(d[1,])/max(d[2,])
> adjusted <- d
> adjusted[2,] <- scale*adjusted[2,]
> barplot(adjusted, beside = TRUE)
> ticks <- pretty(d[2,])
> axis(side = 4, at = ticks*scale, labels = ticks)
>
> Duncan Murdoch
>
>


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
Thanks Duncan.
I am sorry I cannot scale second row (d[2,]).
I was looking for a way to plot d[2,] values next to d[1,]  with a
right side axis=4  on right side. -2,-1,0,1,2
thanks
Adrian

On Wed, Oct 12, 2016 at 12:42 PM, Duncan Murdoch
 wrote:
> On 12/10/2016 12:20 PM, Adrian Johnson wrote:
>>
>> Dear group,
>> I have been struggling to barplot two different measurements from one
>> subject. These two measures differ in range.  I want to plot row 1
>> axis on left side and row 2 values on right side.
>>
>> For a given column I want to plot GN and CN next to each other.
>>
>> my dput code is below
>> :
>>
>> structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
>> 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
>> "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
>> )))
>>
>>
>> As you can see:
>> DC5 DC8 DC14 DC18 DC19 DC20 DC23
>> GN 112 579  131 2234 2892  528  582
>> CN   0   112102
>>
>> GN values are range from 100 - 3000
>> while CN are always -2 or -1 or 0 or 1 or 2
>>
>> Also I cannot log GN values and plot because a difference in 100 units
>> also matters in my experiment.
>>
>> Any help would be greatly appreciated.
>
>
> I would simply rescale one row and add a second axis.  For example, if d
> holds your matrix:
>
> scale <- max(d[1,])/max(d[2,])
> adjusted <- d
> adjusted[2,] <- scale*adjusted[2,]
> barplot(adjusted, beside = TRUE)
> ticks <- pretty(d[2,])
> axis(side = 4, at = ticks*scale, labels = ticks)
>
> Duncan Murdoch
>
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
Hi Adams,
The story I am trying to show visually relationship between GN and CN
for every column. Each column represents a patient. In each patient, a
particular chromosome region (CN) is either lost (-2 or -1) or gained
(1 or 2). Typically if loss (one copy loss - as humans have pair of
chromosome) or homozygous (two copies loss) theoretically indicate
decrease in number of copies of gene located in that region of
chromosome. The number of copies of a gene located in that chromosomal
regions are indicated by GN.
through this barplot, I intend to show that in 7 cases (columns) if a
relationship exist by plotting GN and CN next to each other.  If I log
values in GN, I am loosing the minor differences between cases in GN.
hope I could convince/explain.
thanks
adrian

On Wed, Oct 12, 2016 at 12:36 PM, Adams, Jean  wrote:
> Adrian,
>
> What story are you trying to tell?  Or what question are you trying to
> answer by visualizing these data?  How is a bar plot of these numbers going
> to help?  I'm just wondering if perhaps a different visualization might make
> more sense, for example, a scatter plot of GN vs. CN.
>
> m <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
>   528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
>   "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
>   )))
> plot(m["GN", ], m["CN", ])
>
> Jean
>
>
> On Wed, Oct 12, 2016 at 11:20 AM, Adrian Johnson 
> wrote:
>>
>> Dear group,
>> I have been struggling to barplot two different measurements from one
>> subject. These two measures differ in range.  I want to plot row 1
>> axis on left side and row 2 values on right side.
>>
>> For a given column I want to plot GN and CN next to each other.
>>
>> my dput code is below
>> :
>>
>> structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
>> 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
>> "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
>> )))
>>
>>
>> As you can see:
>>DC5 DC8 DC14 DC18 DC19 DC20 DC23
>> GN 112 579  131 2234 2892  528  582
>> CN   0   112102
>>
>> GN values are range from 100 - 3000
>> while CN are always -2 or -1 or 0 or 1 or 2
>>
>> Also I cannot log GN values and plot because a difference in 100 units
>> also matters in my experiment.
>>
>> Any help would be greatly appreciated.
>>
>> Thanks
>> Adrian
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Duncan Murdoch

On 12/10/2016 12:20 PM, Adrian Johnson wrote:

Dear group,
I have been struggling to barplot two different measurements from one
subject. These two measures differ in range.  I want to plot row 1
axis on left side and row 2 values on right side.

For a given column I want to plot GN and CN next to each other.

my dput code is below
:

structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
"CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
)))


As you can see:
DC5 DC8 DC14 DC18 DC19 DC20 DC23
GN 112 579  131 2234 2892  528  582
CN   0   112102

GN values are range from 100 - 3000
while CN are always -2 or -1 or 0 or 1 or 2

Also I cannot log GN values and plot because a difference in 100 units
also matters in my experiment.

Any help would be greatly appreciated.


I would simply rescale one row and add a second axis.  For example, if d 
holds your matrix:


scale <- max(d[1,])/max(d[2,])
adjusted <- d
adjusted[2,] <- scale*adjusted[2,]
barplot(adjusted, beside = TRUE)
ticks <- pretty(d[2,])
axis(side = 4, at = ticks*scale, labels = ticks)

Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adams, Jean
Adrian,

What story are you trying to tell?  Or what question are you trying to
answer by visualizing these data?  How is a bar plot of these numbers going
to help?  I'm just wondering if perhaps a different visualization might
make more sense, for example, a scatter plot of GN vs. CN.

m <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
  528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
  "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
  )))
plot(m["GN", ], m["CN", ])

Jean


On Wed, Oct 12, 2016 at 11:20 AM, Adrian Johnson 
wrote:

> Dear group,
> I have been struggling to barplot two different measurements from one
> subject. These two measures differ in range.  I want to plot row 1
> axis on left side and row 2 values on right side.
>
> For a given column I want to plot GN and CN next to each other.
>
> my dput code is below
> :
>
> structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L,
> 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN",
> "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23"
> )))
>
>
> As you can see:
>DC5 DC8 DC14 DC18 DC19 DC20 DC23
> GN 112 579  131 2234 2892  528  582
> CN   0   112102
>
> GN values are range from 100 - 3000
> while CN are always -2 or -1 or 0 or 1 or 2
>
> Also I cannot log GN values and plot because a difference in 100 units
> also matters in my experiment.
>
> Any help would be greatly appreciated.
>
> Thanks
> Adrian
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread S Ellison
I have suspect that the most common answer to this will be 'don't', for all the 
reasons statisticians don't like mixing vertical scales on the same plot. See 
http://www.perceptualedge.com/articles/visual_business_intelligence/dual-scaled_axes.pdf
 for one article on that topic.

But if you must, is there any reason you can't divide the first row by (say) 
1000, barplot normally with axes=false, and then put an explicit axis up each 
side with something like
axis(2, at=seq(0,3, 0.5), labels= seq(0,2500,500)) ) #first row axis, left 
column
axis(4)

S Ellison


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Adrian
> Johnson
> Sent: 12 October 2016 17:21
> To: r-help
> Subject: [R] barplot beside=TRUE - values differ on scales
> 
> Dear group,
> I have been struggling to barplot two different measurements from one
> subject. These two measures differ in range.  I want to plot row 1 axis on 
> left
> side and row 2 values on right side.
> 
> For a given column I want to plot GN and CN next to each other.
> 
> my dput code is below
> :
> 
> structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L, 528L, 0L, 
> 582L, 2L),
> .Dim = c(2L, 7L), .Dimnames = list(c("GN", "CN"), c("DC5", "DC8", "DC14",
> "DC18", "DC19", "DC20", "DC23"
> )))
> 
> 
> As you can see:
>DC5 DC8 DC14 DC18 DC19 DC20 DC23
> GN 112 579  131 2234 2892  528  582
> CN   0   112102
> 
> GN values are range from 100 - 3000
> while CN are always -2 or -1 or 0 or 1 or 2
> 
> Also I cannot log GN values and plot because a difference in 100 units also
> matters in my experiment.
> 
> Any help would be greatly appreciated.
> 
> Thanks
> Adrian
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.