R 治疗随机化
我有一个8行12列的矩阵,随机分布了10个不同的处理,有9个重复,最后一个处理只有6个重复。代码可能是多余的,但这是第一个想到的,并且起了作用。我只是想制定一个计划,以便我可以在实验室中轻松遵循,以避免错误:R 治疗随机化,r,matrix,data-processing,R,Matrix,Data Processing,我有一个8行12列的矩阵,随机分布了10个不同的处理,有9个重复,最后一个处理只有6个重复。代码可能是多余的,但这是第一个想到的,并且起了作用。我只是想制定一个计划,以便我可以在实验室中轻松遵循,以避免错误: library(ggplot2) library(RColorBrewer) library(reshape2) library(scales) replicates<-c(rep(seq(1:11),c(rep(9,10),6)));replicates dimna<-l
library(ggplot2)
library(RColorBrewer)
library(reshape2)
library(scales)
replicates<-c(rep(seq(1:11),c(rep(9,10),6)));replicates
dimna<-list(c("A","B","C","D","E","F","G","H"),seq(1,12,1))
plate<-array(sample(replicates),dim=c(8,12),dimnames=dimna);plate
platec<-melt(plate);platec
guide<-ggplot(platec,aes(Var2,Var1,fill=factor(value))) + geom_tile()+geom_text(aes(fill=factor(value),label=value)) + ylim(rev(levels(platec$Var1))) + theme_bw() + theme(panel.grid.major.y=element_blank(),panel.grid.minor.y=element_blank(),panel.grid.major.x=element_blank(), axis.text.x=element_text(size=10), axis.title.y=element_blank(), axis.text.y=element_text(size=12)) + scale_fill_brewer(name="",palette="Spectral") + scale_x_continuous("",labels=c(seq(1,12,1)),breaks=c(seq(1,12,1)));guide
。
.
或是喧闹的时尚:
A1 0.12 0.13 0.15 0.18 0.1784
A2 0.2 0.21 0.248 0.46 0.14
A3 0.124 0.6 0.58 0.47 0.95
A4 0.14 0 0.4 0.3 0.7
A5 0.4 0 0.2 0.21 0.248
A6 0.18 0.58 0.248 0.2 0.21
A7 0.46 0.4 0.2 0.21 0.248
A8 0.47 0.2 0.18 0.58 0.248
在R中是否有一种方法可以将随机矩阵与我收集的数据关联起来,我甚至不知道如何开始。我真的很抱歉没有尝试,但我真的不知道如何开始我想我知道你在问什么。。。如果这不合理,请告诉我。 您首先需要有一个设计数据帧-让我们制作一个虚拟板:
Wells <- paste0(rep(LETTERS[1:8],each=12), rep(1:12, times = 8))
design <- data.frame(Wells, ID = sample(letters[1:10], 96, replace = TRUE))
Wells我想我知道你在问什么。。。如果这不合理,请告诉我。
您首先需要有一个设计数据帧-让我们制作一个虚拟板:
Wells <- paste0(rep(LETTERS[1:8],each=12), rep(1:12, times = 8))
design <- data.frame(Wells, ID = sample(letters[1:10], 96, replace = TRUE))
井
#dummy result data
result <- data.frame(Wells, measure = rnorm(96, 0.5))
result_whole <- merge(design, result)
head(result_whole)
# Wells ID measure
#1 A1 j -0.4408472
#2 A10 d -0.5852285
#3 A11 d 1.0379943
#4 A12 e 0.6917493
#5 A2 g 0.8126982
#6 A3 b 2.0218953