Hello,
I am trying to create multiple scatter plot graphs. I have 1 independent
variable (Age - weeks post conception) and 18 dependent variables ("Gene
n"
Expression) in one csv file. Is there a way to set up a looped function to
produce 18 individual scatterplots? At the moment, I am writing the plot()
function out 18 times to make the 18 graphs. My code is below and csv file
is attached.
*Code*
wd <- setwd("~/Dropbox/Steve/SM Research Projects/Allen Brain Bank
Project/Allen Brain Bank Inflammatory Markers Project Matlab:R/Other/2018
Tests")
list.files(wd)
mydata <- read.csv("Glutamate.Genes.V1.csv")
mydata
plot(mydata$Age..weeks.post.conception., mydata$GluA1..GRIA1..Expression)
plot(mydata$Age..weeks.post.conception.,
mydata$GluA2..GluR2.GRIA2..Expression), etc
Thank you for your time and help.
Regards,
Steven
Hi Steven,
Sad to say that your CSV file didn't make it to the list and I can't
access the data via your Dropbox account. Therefore we don't know the
structure of "mydata". If you are able to plot the data as in your
example, this might help:
genexp<-matrix(runif(360,1,2),ncol=18)
colnames(genexp)<-paste("GluA.",1:18,"GRIA",1:18,"..Expression",sep="")
mydata<-cbind(Age..weeks.post.conception=20:38,genexp)
for(genecol in colnames(mydata)[2:19]) {
png(paste0(genecol,".png"))
plot(mydata$Age..weeks.post.conception,mydata$genecol)
}
Jim
On Mon, May 21, 2018 at 9:05 AM, STEVEN MANCINI <mancinsj at mcmaster.ca>
wrote:> Hello,
>
> I am trying to create multiple scatter plot graphs. I have 1 independent
> variable (Age - weeks post conception) and 18 dependent variables
("Gene n"
> Expression) in one csv file. Is there a way to set up a looped function to
> produce 18 individual scatterplots? At the moment, I am writing the plot()
> function out 18 times to make the 18 graphs. My code is below and csv file
> is attached.
>
> *Code*
> wd <- setwd("~/Dropbox/Steve/SM Research Projects/Allen Brain Bank
> Project/Allen Brain Bank Inflammatory Markers Project Matlab:R/Other/2018
> Tests")
> list.files(wd)
> mydata <- read.csv("Glutamate.Genes.V1.csv")
> mydata
>
> plot(mydata$Age..weeks.post.conception., mydata$GluA1..GRIA1..Expression)
> plot(mydata$Age..weeks.post.conception.,
> mydata$GluA2..GluR2.GRIA2..Expression), etc
>
> Thank you for your time and help.
>
> Regards,
> Steven
> ______________________________________________
> R-help at 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.
As Jim says, "No data". R-help is very fussy about what files it will
accept.? You might try changing the extention to txt.? However the preferred way
here is to use the dput() command and paste the results into the post.? See
?dput for details.
On Monday, May 21, 2018, 1:40:59 a.m. EDT, STEVEN MANCINI <mancinsj at
mcmaster.ca> wrote:
Hello,
I am trying to create multiple scatter plot graphs. I have 1 independent
variable (Age - weeks post conception) and 18 dependent variables ("Gene
n"
Expression) in one csv file. Is there a way to set up a looped function to
produce 18 individual scatterplots? At the moment, I am writing the plot()
function out 18 times to make the 18 graphs. My code is below and csv file
is attached.
*Code*
wd <- setwd("~/Dropbox/Steve/SM Research Projects/Allen Brain Bank
Project/Allen Brain Bank Inflammatory Markers Project Matlab:R/Other/2018
Tests")
list.files(wd)
mydata <- read.csv("Glutamate.Genes.V1.csv")
mydata
plot(mydata$Age..weeks.post.conception., mydata$GluA1..GRIA1..Expression)
plot(mydata$Age..weeks.post.conception.,
mydata$GluA2..GluR2.GRIA2..Expression), etc
Thank you for your time and help.
Regards,
Steven
______________________________________________
R-help at 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]]
Here is a simplified example:
dat <- data.frame(x=1:4, y1=runif(4), y2=runif(4), y3=4:1)
for (icol in 2:4) plot(dat[,1] , dat[,icol] )
(not tested, so hopefully all my parentheses are balanced, no typos, etc.)
This shows the basic principle.
An alternative is to construct each column name as a text string within the
loop, and use that in the plot() call.
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
?On 5/20/18, 4:05 PM, "R-help on behalf of STEVEN MANCINI"
<r-help-bounces at r-project.org on behalf of mancinsj at mcmaster.ca>
wrote:
Hello,
I am trying to create multiple scatter plot graphs. I have 1 independent
variable (Age - weeks post conception) and 18 dependent variables
("Gene n"
Expression) in one csv file. Is there a way to set up a looped function to
produce 18 individual scatterplots? At the moment, I am writing the plot()
function out 18 times to make the 18 graphs. My code is below and csv file
is attached.
*Code*
wd <- setwd("~/Dropbox/Steve/SM Research Projects/Allen Brain Bank
Project/Allen Brain Bank Inflammatory Markers Project Matlab:R/Other/2018
Tests")
list.files(wd)
mydata <- read.csv("Glutamate.Genes.V1.csv")
mydata
plot(mydata$Age..weeks.post.conception., mydata$GluA1..GRIA1..Expression)
plot(mydata$Age..weeks.post.conception.,
mydata$GluA2..GluR2.GRIA2..Expression), etc
Thank you for your time and help.
Regards,
Steven
______________________________________________
R-help at 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.