I was following a tutorial on Youtube on how to run datasets and when the woman put her bottomly files into the script and then loaded them, they went into the Global Environment. I did the same, and they loaded into the environment too. Then she ran
Which I proceeded to copy and run one-by-one and all but the sdvec command went into the Data tab, when they should have gone to the Values tab. Then I tried running the last command which was to plot the data in the bottomly file and got an error. Please advise me on where I may have gone wrong.
Hi Tyler, it's hard to figure out why your code runs an error, based on your minimal information (we have no clue how your data looks like, what your data represents and where the function cpm() cames from...!). I can just guess what happend... But your plot will definitely not appear if the input variable sdvec is missing.
To make it more easy to help you, please try to use reprex in future. Below is a link to a cool FAQ from Andrés, try it out
So, now some reprex in action, based on your code. I have added a sample data set (just some random numbers) and also load the Bioconductor package 'edgeR' (I hope that's your cpm()-function).
#> Lade nötiges Paket: limma
#set seed for the random numbers
#sampling random numbers/counts (e.g. as example for your digital gene expression data loaded in R etc.)
y <- matrix(rnbinom(100,size=1,mu=10), ncol=2)
#compute cpm ('counts per million...?') and (natural) log-transform
cpm.mat <- log(cpm(y))
#calculate mean/average out of the two replicates (each column represents a replicate...?)
mean.vec <- apply(cpm.mat, 1, mean)
#calculate standard deviation/variability out of the two replicates
sdvec <- apply(cpm.mat, 1, sd)
#plot mean vs. standard deviation (set some plotting options)
plot(mean.vec, sdvec, main="2 replicates", ylab="sd", xlab="Average logCPM")