ggplot2 - For loop assigns variable while i want to plot something with qplot (R) -
so have following loop:
for (count in 1:19){ png(paste0(colnames(fdd$rawcounts)[count], ".pdf")) qplot(y = log2(fdd$rawcounts[,count]), main = colnames(fdd$rawcounts)[count]) dev.off() }
which should plot count data put head here:
structure(c(11l, 3l, 12l, 8l, 15l, 2l, 5l, 2l, 8l, 7l, 6l, 10l, 6l, 1l, 7l, 4l, 2l, 1l, 3l, 0l, 4l, 4l, 2l, 5l, 8l, 0l, 13l, 4l, 10l, 7l, 2l, 1l, 2l, 4l, 7l, 7l, 14l, 4l, 25l, 17l, 14l, 16l, 4l, 2l, 5l, 5l, 5l, 2l, 9l, 5l, 11l, 8l, 1l, 4l, 10l, 8l, 8l, 7l, 9l, 5l, 9l, 15l, 14l, 11l, 16l, 8l, 11l, 4l, 3l, 6l, 3l, 0l, 6l, 3l, 4l, 6l, 1l, 4l, 11l, 11l, 12l, 6l, 2l, 6l, 7l, 9l, 22l, 8l, 13l, 7l, 6l, 1l, 4l, 5l, 6l, 2l, 4l, 2l, 6l, 7l, 3l, 2l, 6l, 3l, 3l, 2l, 5l, 5l, 9l, 2l, 6l, 5l, 4l, 2l), .dim = c(6l, 19l), .dimnames = structure(list(feature = c("chr10:100000001-100000500", "chr10:10000001-10000500", "chr10:1000001-1000500", "chr10:100000501-100001000", "chr10:100001-100500", "chr10:100001001-100001500"), sample = c("k562_faire_acla_4hr_1", "k562_faire_acla_4hr_2", "k562_faire_daun_4hr_1", "k562_faire_daun_4hr_2", "k562_faire_etop_4hr_1", "k562_faire_etop_4hr_2", "k562_faire_untreated", "faire.seq_k562_2methyldoxo_a", "faire.seq_k562_2methyldoxo_b", "faire.seq_k562_ctr_a", "faire.seq_k562_ctr_b", "faire.seq_k562_doxo_10um_4hrs_a", "faire.seq_k562_doxo_10um_4hrs_b", "faire.seq_k562_epirubicin_a", "faire.seq_k562_epirubicin_b", "faire.seq_k562_mtx_40um_4hrs_a", "faire.seq_k562_mtx_40um_4hrs_b", "faire.seq_k562_mtx_5um_4hrs_a", "faire.seq_k562_mtx_5um_4hrs_b")), .names = c("feature", "sample" )))
now if try plot data gives me variable called count , value 19l. while expect 19 plots drawn. why happening?
thanks!
this works me:
for (count in 1:19){ pdf(paste0(colnames(df)[count], ".pdf")) print(qplot(y = log2(df[, count]), main = colnames(df)[count])) dev.off() }
a couple of changes:
- i read in data df. turns out matrix, adjusted subsetting accordingly.
- i wrapped
qplot
function inprint
function forces figure created. - finally, switched
png
functionpdf
seemed files trying create based onpaste0
result.
Comments
Post a Comment