From 5bc050cd7522151f4ad161fd1d981693c3d7c883 Mon Sep 17 00:00:00 2001 From: faroo002 <muhammad.farooq@wur.nl> Date: Fri, 6 Nov 2020 07:45:39 +0100 Subject: [PATCH] uploaded --- code/BLUES.R | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 code/BLUES.R diff --git a/code/BLUES.R b/code/BLUES.R new file mode 100644 index 0000000..c497179 --- /dev/null +++ b/code/BLUES.R @@ -0,0 +1,40 @@ + +###B6 Script Specialized for MPI experiment August-September 2018 by Tom Theeuwen################################### + +library(lme4); library(lmerTest); library(pbkrtest) +setwd('../data/') +data <- na.omit(as.data.frame(read.table("s8.csv", sep = ",", header = TRUE))) +data$Basin <- factor(data$Basin) +data$Replicate <- factor(data$Replicate) +data$Table_pos <- factor(data$Table_pos) +data$Image_pos <- factor(data$Image_pos) +data$x <- factor(data$x) +data$y <- factor(data$y) +data$Sowing_X <- factor(data$Sowing_X) +data$Sowing_Y <- factor(data$Sowing_Y) +data$Sowing_Block <- factor(data$Sowing_Block) + +BLUES_overview <- NULL +extract_names <- sapply(data$Genotype,levels)[,1] +BLUES_overview<-rbind(BLUES_overview,extract_names) +BLUE_new <- NULL +start_point = 13 # enter column where you want to start + +for(x in start_point:ncol(data)){ + name <- colnames(data)[x] + variable <- data[,x] + mm1 <- lmer(variable ~ Genotype + (1|Image_pos) + (1|x) + (1|y) + (1|Sowing_Block), data=data,REML=TRUE) + BLUE <- fixef(mm1) + MN1 <- BLUE[1] + BLUE_new[1] <- MN1 + for(i in 2:length(BLUE)){ + BLUE_new[i] <- MN1 + BLUE[i] + } + BLUES_overview <- rbind(BLUES_overview, BLUE_new) + print(name) +} +rownames(BLUES_overview)=c() +mat=t(BLUES_overview) +colnames(mat)=c("Genotype","T13_1","T13_2","T13_3","T13_4","T14_1","T14_2","T14_3","T14_4","T14_5","T14_6","T14_7","T14_8","T15_1","T15_2","T15_3","T15_4","T15_5","T15_6","T15_7","T15_8","T16_1","T16_2","T16_3","T16_4","T16_5","T16_6","T16_7","T16_8","T17_1","T17_2","T17_3","T17_4","T17_5","T17_6","T17_7","T17_8","T18_1","T18_2","T18_3","T18_4","T18_5","T18_6","T18_7","T18_8","T19_1","T19_2","T19_3","T19_4","T19_5","T19_6","T19_7","T19_8","T20_1","T20_2") +write.csv(mat, "s9.csv",quote=F,row.names=F) + -- GitLab