#randomly generates 10000 number in a matix[100,100] rand_data <- matrix(ncol=100,nrow=100,data=runif(10000,1,100)) #getting log2 of the data and transposing the results rand_data_t_log2 <- t(log2(rand_data)) #calculating the min, max and average for rows and columns mean_cols <- apply(rand_data,2,mean) mean_rows <- apply(rand_data,1,mean) min_rows <- apply(rand_data,1,min) min_cols <- apply(rand_data,2,min) max_rows <- apply(rand_data,1,max) max_cols <- apply(rand_data,2,max) #making plot and saving results in a pdf file pdf("Rand_Data_QC.pdf") g_range <- range(0,min_rows,max_rows) plot(mean_rows, type="l", col="blue", ylim=g_range, ann=FALSE) lines(mean_cols, type="l", col="red") lines(max_rows, type="l", col="green") lines(max_cols, type="l", col="purple") lines(min_rows, type="l", col="royalblue") lines(min_cols, type="l", col="coral") legend(80,40,c("Mean Rows","Mean Cols","Max Rows","Max Cols","Min Rows","Min Cols"),col=c("blue","red","green","purple","coral","royalblue"),lty=1,cex=0.55) dev.off() #saving data files write.csv(rand_data,"rand_data.csv") write.csv(rand_data_t_log2,"rand_data_t_log2.csv")