[R] Force printing of excluded axis annotations

2012-02-08 Thread Justin Fincher
Howdy,
   This should be simple, but I am finding that I can't find a simple
solution.  I have a plot to which I am manually adding the annotations
to the y-axis with this command:

axis(2, 
c(-4,-3,-2,-1,0,1,2,3,4,5,6,7),labels=c(-4,-3,-2,-1,0,1,2,3,4,5,6,7),cex.axis=8)

The issue is that, apparently, R doesn't think that the -1 can fit,
even though there is most certainly enough space.  Is there a way to
force R to print all the annotations I give it, regardless of
proximity or to reduce the space it believes it needs? Thank you.

- Fincher

__
R-help@r-project.org mailing list
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] adding hyperlinked text to pdf plot

2011-12-05 Thread Justin Fincher
For example, say I am plotting some data that is genomic and therefore
maps to a specific locus on the human genome, like a gene.  I was
hoping to have the title of the plot display the gene name, but have
it be a link so that clicking on it would take you to those
coordinates on a public browser, like USCS's genome browser.  So
basically, I was hoping to have text in a plot generated by R function
as a normal html-style link.

- Fincher


On Mon, Dec 5, 2011 at 14:09, Yihui Xie  wrote:
> It seems I missed the context of this post -- who is "you", and what
> is "something other than the URL"?
>
> I feel the tikzDevice package should be an option for the task.
>
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
> On Mon, Dec 5, 2011 at 12:39 PM, Justin Fincher  wrote:
>> Howdy,
>>   I have read that if you put a URL in the text of a plot being saved
>> into pdf, the result is a functional hyperlink. I am interested in
>> having text in a plot that is linked to a URL, but I would like the
>> text to be something other than the URL. Is this possible? Thank you.
>>
>> - Fincher
>>
>> __
>> R-help@r-project.org mailing list
>> 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 message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>

__
R-help@r-project.org mailing list
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] adding hyperlinked text to pdf plot

2011-12-05 Thread Justin Fincher
Howdy,
   I have read that if you put a URL in the text of a plot being saved
into pdf, the result is a functional hyperlink. I am interested in
having text in a plot that is linked to a URL, but I would like the
text to be something other than the URL. Is this possible? Thank you.

- Fincher

__
R-help@r-project.org mailing list
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] Creating a simple 1-row heatmap

2011-08-08 Thread Justin Fincher
Thank you for that.  I had to do some tweaking, but I managed to get it
working.  In case anyone wants to do something similar, here's my solution.

n = sample(1:50,25)
g = gray(1-(n/max(n))) # the subtraction from 1 reverses the colors.  rev()
just reverses the order of the colors.
image(as.matrix(seq(1:25)),col=g) # if I passed it n, it drew the colors all
over the place.  This draws them in order so that filling in with g aligns
to the original data.

Thank you again for your help.

- Fincher


On Mon, Aug 8, 2011 at 18:01, R. Michael Weylandt <
michael.weyla...@gmail.com> wrote:

> Would the image() function do what you need?
>
> n = sample(1:50,25);
> g = gray(n/max(n)) # set up color palate
> g = rev(g) # reverse so max is black instead of white
> image(as.matrix(n),col=g) # Requires a matrix input
>
> I think you should be able to handle axes/ labels/ etc as normal:
>
> image(as.matrix(n),col=g,xaxt="n",yaxt="n",main="Very Important Data")
>
> If you adjust the aspect ratio, you can get your desired bar shape/size.
>
> Michael Weylandt
>
> On Mon, Aug 8, 2011 at 5:10 PM, Justin Fincher  wrote:
>
>> Howdy,
>>   I am trying to make a simple monochrome heatmap from 1 row of data.
>>  Essentially, I just want a long bar where black represents the max value
>> in
>> the data, white is the minimum, and all values in between are interpolated
>> appropriately.  I have tried using heatmap and heatmap.2, but both have
>> issues. heatmap seems to be restricted to only drawing a square plot, and
>> this data requires a long, thin plot (e.g. 50px tall by 3000 px wide). For
>> heatmap.2, the plots will draw the dimensions I prefer, but when I do a
>> small sample the coloring seems to not correlate with the data even though
>> I
>> have Rowv and Colv both set to FALSE.  Any recommendations about the best
>> way to make a clean, simple heatmap from a single array of positive
>> integers
>> would be greatly appreciated.
>>
>> - Fincher
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> 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 message has been scanned for viruses and
> dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is
> believed to be clean.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Creating a simple 1-row heatmap

2011-08-08 Thread Justin Fincher
Howdy,
   I am trying to make a simple monochrome heatmap from 1 row of data.
 Essentially, I just want a long bar where black represents the max value in
the data, white is the minimum, and all values in between are interpolated
appropriately.  I have tried using heatmap and heatmap.2, but both have
issues. heatmap seems to be restricted to only drawing a square plot, and
this data requires a long, thin plot (e.g. 50px tall by 3000 px wide). For
heatmap.2, the plots will draw the dimensions I prefer, but when I do a
small sample the coloring seems to not correlate with the data even though I
have Rowv and Colv both set to FALSE.  Any recommendations about the best
way to make a clean, simple heatmap from a single array of positive integers
would be greatly appreciated.

- Fincher

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] inconsistency with cor() - "x must be numeric"

2010-12-13 Thread Justin Fincher
I apologize for the lack of example.  I was trying not to be too long
winded.  Below is the first portion of my function that is causing the
error. (I'm including both calls to cor(), though it quits after the first
throws an error).  I do not believe he has redefined cor() as he is a novice
user and we tried this after starting a fresh session.  And I will look into
upgrading.  I realize it is a little out of date since it is the version in
the repository for my distribution and not the latest-and-greatest from R.
 I just didn't realize a change like that would be made that would
(seemingly to me) reduce functionality. Thank you again for your help.

- Fincher

   # As they don't change, hard code gene density values
   gene_densities =
data.frame(chrom=c("chr1","chr2","chr3","chr4","chr5","chr6","chr7",

"chr8","chr9","chr10","chr11","chr12","chr13",

"chr14","chr15","chr16","chr17","chr18","chr19",

"chr20","chr21","chr22","chrX","chrY"),

 avg_density=c(10.19,6.457,6.71,4.917,6.083,7.491,7.453,
   5.939,7.27,7.132,11.38,9.429,3.757,
   7.607,8.455,11.81,17.84,4.649,26.52,
   11.19,6.51,11.28,7.535,2.931))

   acc_averages = c()

   # subset out relevant data
   accessibility_data = subset(accessibility_data,
accessibility_data$V9==";color=00")

   # calculate mean accessibility value for each chromosome
   for(i in seq(1,22)){
  sub = paste("chr",i,sep="")
  temp = subset(accessibility_data,accessibility_data$V1==sub)
  acc_averages = rbind(acc_averages,c(sub,as.double(mean(temp$V6
   }
   temp = subset(accessibility_data,accessibility_data$V1=="chrX")
   acc_averages = rbind(acc_averages,c("chrX",as.double(mean(temp$V6

   # Output the correlation without including chromosome Y
   correlation = cor(acc_averages[,2],gene_densities$avg_density[1:23])
   cat("Correlation w/o chrY:",correlation,'\n')

   temp = subset(accessibility_data,accessibility_data$V1=="chrY")
   acc_averages = rbind(acc_averages,c("chrY",mean(temp$V6)))

   # Output overall correlation
   correlation = cor(acc_averages[,2],gene_densities$avg_density)
   cat("Correlation w/chrY:",correlation,'\n')


On Mon, Dec 13, 2010 at 17:06, Joshua Wiley  wrote:

> Hi Fincher,
>
> cor() only works on numeric arguments now (as of R 2.11 or 2.10 if
> memory serves).  So, I would update your function to ensure that you
> are only passing numeric data to cor() and the error should go away
> (it will probably be easier on you if you can update your version of R
> to the latest and greatest...quite a bit has changed since 2.8.1).  If
> you post a reproducible example of your function, I'm sure we can help
> update it.
>
> Cheers,
>
> Josh
>
> On Mon, Dec 13, 2010 at 1:56 PM, Justin Fincher 
> wrote:
> > Howdy,
> >   I have written a small function to generate a simple plot and my
> > colleague is having an error when attempting to run it.  Essentially I
> loop
> > through categories in a data frame and take the average value for each
> > category The categories are in $V1, subset first then mean taken and
> > concatenated to previous values using rbind(c("label",mean(data$V6)).
>  The
> > result is a two-column matrix with labels in column one and values in
> column
> > two.  Within the function I calculate the correlation of column two and
> > another set of values that are part of the function.  On my computer
> (linux
> > box running R 2.8.1) the function runs correctly.  On my colleague's
> > computer (Windows box running R 2.12) the function throws an error at the
> > cor() function call saying that "x must be numeric."  We are running on
> the
> > exact same data set and source'ing the same function definition.  Any
> help
> > would be appreciated.
> >
> > - Fincher
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > 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.
> >
>
>
>
> --
> Joshua Wiley
> Ph.D. Student, Health Psychology
> University of California, Los Angeles
> http://www.joshuawiley.com/
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] inconsistency with cor() - "x must be numeric"

2010-12-13 Thread Justin Fincher
Howdy,
   I have written a small function to generate a simple plot and my
colleague is having an error when attempting to run it.  Essentially I loop
through categories in a data frame and take the average value for each
category The categories are in $V1, subset first then mean taken and
concatenated to previous values using rbind(c("label",mean(data$V6)).  The
result is a two-column matrix with labels in column one and values in column
two.  Within the function I calculate the correlation of column two and
another set of values that are part of the function.  On my computer (linux
box running R 2.8.1) the function runs correctly.  On my colleague's
computer (Windows box running R 2.12) the function throws an error at the
cor() function call saying that "x must be numeric."  We are running on the
exact same data set and source'ing the same function definition.  Any help
would be appreciated.

- Fincher

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Issue increasing DPI on a png output of a plot

2010-09-27 Thread Justin Fincher
Howdy,
  I have created a set of plots, but I wish to increase the dpi to 300
(instead of the default 72).  From the documentation, I thought that
the "res" parameter to png should accomplish this, but it appears to
greatly alter the appearance of my plot. (plot area becomes smaller,
plot lines become thicker, etc.)  It is my understanding that
increasing the dpi should not change the look of the plot, just the
quality.  Any help in recreating my plots in 300 dpi would be greatly
appreciated.

- Fincher

__
R-help@r-project.org mailing list
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] Issue increasing DPI on a png output of a plot

2010-09-27 Thread Justin Fincher
Howdy,
  I have created a set of plots, but I wish to increase the dpi to 300
(instead of the default 72).  From the documentation, I thought that
the "res" parameter to png should accomplish this, but it appears to
greatly alter the appearance of my plot. (plot area becomes smaller,
plot lines become thicker, etc.)  It is my understanding that
increasing the dpi should not change the look of the plot, just the
quality.  Any help in recreating my plots in 300 dpi would be greatly
appreciated.

- Fincher

__
R-help@r-project.org mailing list
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] plotting lines when data has missing/NA values

2010-07-08 Thread Justin Fincher
Howdy,
   I have done many searches and can't seem to find a way around this.
 I am reading in a .csv file where each row is a dataset and each
column represents a position.  The values are sparse (there are 2003
positions but usually only 100-200 values) and the idea is to be able
to plot each dataset (row) and overlay them in different combinations.
 What I would like to do is have a plot where each data point is
connected by a line, but since there are numerous NA values between
each real data value, I have yet to find out to do this.  Essentially
I would like each data point to be connected to the next non-NA data
point.  I also thought about subsetting the relevant data points out,
but am unsure how to do this while retaining the column numbers so
they will not be affected spatially.  Any help would be greatly
appreciated.

- Fincher

__
R-help@r-project.org mailing list
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] finding the plot limits generated by default

2010-05-14 Thread Justin Fincher
That worked!  Thank you again for your help.

- Fincher


On Fri, May 14, 2010 at 12:33, Marc Schwartz  wrote:

> Justin,
>
> Try something like this:
>
> par(mfrow = c(2, 1))
>
> drawGffPlots2(data1, data2, trackingDye = TRUE,
>  slice = "chr13", newDev = 0)
>
> plot(densities_subset$V4, densities_subset$V6, type = "h",
> xlim = par("usr")[1:2],
>xaxs = "i",
> xlab = "Position", ylab = "Gene Density")
>
>
> Using 'xaxs = "i"' in the second call to plot() should fix the x axis range
> at the exact values passed for 'xlim'.
>
>
> HTH,
>
> Marc
>
>
> On May 14, 2010, at 11:09 AM, Justin Fincher wrote:
>
> > Thank you for your reply, but I have additional questions.  I agree that
> getting the common ranges before plotting would be the best scenario, it is
> just complicated by the fact that the first plot is generated with a
> function where all the data is passed in and within the function the data is
> subset and plotted so I don't have control over the parameters of the plot.
>  That is why I am trying to just make the second plot (the one I have
> complete control over) match up.  I tried the par("usr") but am having an
> odd result.  Below is from my R console.
> >
> > > par(mfrow=c(2,1))
> > > drawGffPlots2(data1,data2,trackingDye=TRUE,slice="chr13",newDev=0)
> > NULL
> > > par("usr")[1]
> > [1] 14215173
> > >
> plot(densities_subset$V4,densities_subset$V6,type="h",xlim=c(par("usr")[1],par("usr")[2]),xlab="Position",ylab="Gene
> Density")
> > > par("usr")[1]
> > [1] 10062761
> >
> > This creates two rows, runs the function which populates the first row,
> then I check the parameter you suggested so that I may use it for the second
> plot.  I then pass it to plot(), but the axes still don't line up so I check
> the same parameter after the second plot has been drawn and it is very
> different.  Should par("usr")[1] not be exactly the same the second time I
> display it as I passed it as the minimum for the second plot?  Any help
> would be appreciated.
> >
> > - Fincher
> >
> >
> > On Fri, May 14, 2010 at 11:45, Marc Schwartz 
> wrote:
> > On May 14, 2010, at 9:59 AM, Justin Fincher wrote:
> >
> > > I have two datasets that I would like to plot in a single figure.  The
> first
> > > plot is generated by a function that then takes a subset of the data.
>  (It
> > > is biological data so it is usually by chromosome e.g.
> > > function(data1,subset="chr8") ) Since not only are the chromosomes
> different
> > > sizes, but across different datasets there may be different numbers of
> > > points for a single chromosome, I do not know the coordinates on the
> x-axis
> > > prior to running the function.
> > >
> > > I want the scale of the second plot to align to that of the first, but
> I
> > > don't know how to find the default xlim for the graph generated by the
> > > function.  Is there any way to access this information so I can then
> pass it
> > > to the plot() of the second plot?  Thanks!
> > >
> > > - Fincher
> >
> >
> > The result of par("usr") will give you the actual limits of the x and y
> axes (plot region) once the first graphic is drawn to the device. See ?par
> for more information. Note that by default, R will extend the data ranges by
> 4% (see 'xaxs' in ?par).
> >
> > However, you are better off getting the common ?range of the relevant
> values in both subsets of data before plotting and then explicitly set the
> same x and y axis ranges in each plot by using the 'xlim' and 'ylim'
> arguments to plot().
> >
> > HTH,
> >
> > Marc Schwartz
> >
> >
> >
> > --
> > This message has been scanned for viruses and
> > dangerous content by MailScanner, and is
> > believed to be clean.
> >
> >
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] finding the plot limits generated by default

2010-05-14 Thread Justin Fincher
Thank you for your reply, but I have additional questions.  I agree that
getting the common ranges before plotting would be the best scenario, it is
just complicated by the fact that the first plot is generated with a
function where all the data is passed in and within the function the data is
subset and plotted so I don't have control over the parameters of the plot.
 That is why I am trying to just make the second plot (the one I have
complete control over) match up.  I tried the par("usr") but am having an
odd result.  Below is from my R console.

> par(mfrow=c(2,1))
> drawGffPlots2(data1,data2,trackingDye=TRUE,slice="chr13",newDev=0)
NULL
> par("usr")[1]
[1] 14215173
>
plot(densities_subset$V4,densities_subset$V6,type="h",xlim=c(par("usr")[1],par("usr")[2]),xlab="Position",ylab="Gene
Density")
> par("usr")[1]
[1] 10062761

This creates two rows, runs the function which populates the first row, then
I check the parameter you suggested so that I may use it for the second
plot.  I then pass it to plot(), but the axes still don't line up so I check
the same parameter after the second plot has been drawn and it is very
different.  Should par("usr")[1] not be exactly the same the second time I
display it as I passed it as the minimum for the second plot?  Any help
would be appreciated.

- Fincher


On Fri, May 14, 2010 at 11:45, Marc Schwartz  wrote:

> On May 14, 2010, at 9:59 AM, Justin Fincher wrote:
>
> > I have two datasets that I would like to plot in a single figure.  The
> first
> > plot is generated by a function that then takes a subset of the data.
>  (It
> > is biological data so it is usually by chromosome e.g.
> > function(data1,subset="chr8") ) Since not only are the chromosomes
> different
> > sizes, but across different datasets there may be different numbers of
> > points for a single chromosome, I do not know the coordinates on the
> x-axis
> > prior to running the function.
> >
> > I want the scale of the second plot to align to that of the first, but I
> > don't know how to find the default xlim for the graph generated by the
> > function.  Is there any way to access this information so I can then pass
> it
> > to the plot() of the second plot?  Thanks!
> >
> > - Fincher
>
>
> The result of par("usr") will give you the actual limits of the x and y
> axes (plot region) once the first graphic is drawn to the device. See ?par
> for more information. Note that by default, R will extend the data ranges by
> 4% (see 'xaxs' in ?par).
>
> However, you are better off getting the common ?range of the relevant
> values in both subsets of data before plotting and then explicitly set the
> same x and y axis ranges in each plot by using the 'xlim' and 'ylim'
> arguments to plot().
>
> HTH,
>
> Marc Schwartz
>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] finding the plot limits generated by default

2010-05-14 Thread Justin Fincher
I have two datasets that I would like to plot in a single figure.  The first
plot is generated by a function that then takes a subset of the data.  (It
is biological data so it is usually by chromosome e.g.
function(data1,subset="chr8") ) Since not only are the chromosomes different
sizes, but across different datasets there may be different numbers of
points for a single chromosome, I do not know the coordinates on the x-axis
prior to running the function.

I want the scale of the second plot to align to that of the first, but I
don't know how to find the default xlim for the graph generated by the
function.  Is there any way to access this information so I can then pass it
to the plot() of the second plot?  Thanks!

- Fincher

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.