This is RSA analysis of F2 population created from the cross between LA1511 and M248.The seeds for each parents and F2 individuals were germinated on 1/4 ms plates for 4 complete days. At d5, germinated seedlings were transferred to 1/4 ms plates containing 100 mM salt. The plates were scanned from d5 to d9, and seedlings were harvested after 10 days in salt condition. The root tracing of d9 was done by undergraduate Trent Donaldson “20230227_RSA_M248LA1511_F2_100mM_Salt_d9_only_traced”.
getwd()
## [1] "C:/Users/Julkowska Lab/Desktop/R codes by Maryam/BSA"
list.files(pattern = ".csv")
## [1] "F2-d9-1st-batch.csv" "F2-d9-2nd-batch-corrected.csv"
## [3] "F2-d9-2nd-batch.csv" "F2-d9-3rd-batch.csv"
bsa_1st<- read.csv("F2-d9-1st-batch.csv")
bsa_2nd<- read.csv("F2-d9-2nd-batch-corrected.csv")
bsa_3rd<- read.csv( "F2-d9-3rd-batch.csv")
head(bsa_1st)
library(doBy)
BSA_all <- rbind(bsa_1st, bsa_2nd)
BSA_all <- rbind(BSA_all, bsa_3rd)
BSA_all
library(readr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:doBy':
##
## order_by
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
Main_root <- subset(BSA_all, BSA_all$root_order == 0)
Main_root
colnames(Main_root)
## [1] "image" "root_name" "root"
## [4] "length" "vector_length" "surface"
## [7] "volume" "direction" "diameter"
## [10] "root_order" "root_ontology" "parent_name"
## [13] "parent" "insertion_position" "insertion_angle"
## [16] "n_child" "child_density" "first_child"
## [19] "insertion_first_child" "last_child" "insertion_last_child"
MR_data<-Main_root[, c(1:4, 10, 14:17, 19:21)]
MR_data
Lateral_root <- subset(BSA_all, BSA_all$root_order != 0)
Lateral_root
colnames(Lateral_root)
## [1] "image" "root_name" "root"
## [4] "length" "vector_length" "surface"
## [7] "volume" "direction" "diameter"
## [10] "root_order" "root_ontology" "parent_name"
## [13] "parent" "insertion_position" "insertion_angle"
## [16] "n_child" "child_density" "first_child"
## [19] "insertion_first_child" "last_child" "insertion_last_child"
MR_data2 <- subset(MR_data, MR_data$n_child >0)
MR_data2
temporary <- subset(Lateral_root, Lateral_root$parent == MR_data2$root[1])
temporary
dim(temporary)
## [1] 18 21
total_LRL <- sum(temporary$length)
angle_LR.avg <- mean(temporary$insertion_angle)
angle_LR.sd <- sd(temporary$insertion_angle)
LR_number <- dim(temporary)[1]
total_LRL
## [1] 18.59544
angle_LR.avg
## [1] 66.23206
angle_LR.sd
## [1] 13.9429
LR_number
## [1] 18
MR_data2$LRL <- 0
MR_data2$LRno <- 0
MR_data2$LRangle.avg <- 0
MR_data2$LRangle.sd <- 0
MR_data2
MR_data2$LRL[1] <- total_LRL
MR_data2$LRno[1] <- LR_number
MR_data2$LRangle.avg[1] <- angle_LR.avg
MR_data2$LRangle.sd[1] <- angle_LR.sd
MR_data2
MR_data_noChild <- subset(MR_data, MR_data$n_child == 0)
MR_data_noChild
length(MR_data2$root)
## [1] 207
for(i in 2:207){
temporary <- subset(Lateral_root, Lateral_root$parent == MR_data2$root[i])
total_LRL <- sum(temporary$length)
angle_LR.avg <- mean(temporary$insertion_angle)
angle_LR.sd <- sd(temporary$insertion_angle)
LR_number <- dim(temporary)[1]
MR_data2$LRL[i] <- total_LRL
MR_data2$LRno[i] <- LR_number
MR_data2$LRangle.avg[i] <- angle_LR.avg
MR_data2$LRangle.sd[i] <- angle_LR.sd
}
MR_data2$check <- MR_data2$n_child - MR_data2$LRno
MR_data2
colnames(MR_data2)
## [1] "image" "root_name" "root"
## [4] "length" "root_order" "insertion_position"
## [7] "insertion_angle" "n_child" "child_density"
## [10] "insertion_first_child" "last_child" "insertion_last_child"
## [13] "LRL" "LRno" "LRangle.avg"
## [16] "LRangle.sd" "check"
MR_data_Child2 <- MR_data2[,1:16]
MR_data_Child2
MR_data_noChild
#I feel the number for the dim(MR_data_noChild)is pretty low!!!! 10
MR_data_noChild$LRL <- 0
MR_data_noChild$LRno <- 0
MR_data_noChild$LRangle.avg <- 0
MR_data_noChild$LRangle.sd <- 0
MR_all <-rbind(MR_data_Child2, MR_data_noChild)
MR_all
dim(MR_data_Child2)
## [1] 207 16
dim(MR_data_noChild)
## [1] 10 16
dim(MR_all)
## [1] 217 16
MR_all$root_name[51]
## [1] " pl12-s-class2"
text <- strsplit(x = MR_all$root_name[51], split = "-")
text
## [[1]]
## [1] " pl12" "s" "class2"
plate <- text[[1]][1]
plate <- gsub(" ", "", plate)
plate
## [1] "pl12"
#here I am trying to substitute class2 with cross2…but I cannot see these changes being applied later on…
genotype<- text[[1]][3]
genotype<-gsub("class2", "cross2", genotype)
genotype
## [1] "cross2"
cond<-text[[1]][2]
cond
## [1] "s"
dim(MR_all)
## [1] 217 16
for(i in 1:217){
text <- strsplit(x = MR_all$root_name[i], split = "-")
plate <- text[[1]][1]
cond <- text[[1]][2]
genotype <- text[[1]][3]
MR_all$genotype[i] <- genotype
MR_all$condition[i] <- cond
MR_all$plate[i] <- plate
}
MR_all
MR_all$TRS <- MR_all$length + MR_all$LRL
for(i in 1:nrow(MR_all)){
if(MR_all$LRno[i] == 0){
MR_all$aLRL[i] <- 0
} else {
MR_all$aLRL[i] <- MR_all$LRL[i]/ MR_all$LRno[i]
}
}
MR_all$MRpLRL <- MR_all$length / MR_all$LRL
MR_all
length(unique(MR_all$root_name))
## [1] 206
unique(MR_all$root_name)
## [1] " pl5-s-la1511" " pl4-s-la1511" " pl3-s-la1511" " pl2-s-la1511"
## [5] " pl1-s-la1511" " pl5-s-m248" " pl4-s-m248" " pl3-s-m248"
## [9] " pl2-s-m248" " pl1-s-m248" " pl1-s-cross1" " pl2-s-cross1"
## [13] " pl3-s-cross1" " pl4-s-cross1" " pl5-s-cross1" " pl6-s-cross1"
## [17] " pl7-s-cross1" " pl8-s-cross1" " pl9-s-cross1" " p11-s-cross1"
## [21] " pl12-s-cross1" " pl13-s-cross1" " pl14-s-cross1" " pl15-s-cross1"
## [25] " pl16-s-cross1" " pl17-s-cross1" " pl18-s-cross1" " pl19-s-cross1"
## [29] " pl20-s-cross1" " pl21-s-cross1" " pl22-s-cross1" " pl23-s-cross1"
## [33] " pl24-s-cross1" " pl25-s-cross1" " pl26-s-cross1" " pl27-s-cross1"
## [37] " pl28-s-cross1" " pl29-s-cross1" " pl30-s-cross1" " pl1-s-cross2"
## [41] " pl2-s-cross2" " pl3-s-cross2" " pl4-s-cross2" " pl5-s-cross2"
## [45] " pl6-s-cross2" " pl7-s-cross2" " pl8-s-cross2" " pl9-s-cross2"
## [49] " pl10-s-cross2" " pl11-s-cross" " pl12-s-class2" " pl13-s-cross2"
## [53] " pl14-s-cross2" " pl15-s-cross2" " pl16-s-cross2" " pl17-s-cross2"
## [57] " pl18-s-cross2" " pl19-s-cross2" " pl20-s-cross2" " pl21-s-cross2"
## [61] " pl22-s-cross2" " pl23-s-cross2" " pl24-s-cross2" " pl25-s-cross2"
## [65] " pl26-s-cross2" " pl27-s-cross2" " pl28-s-cross2" " pl29-s-cross2"
## [69] " pl30-s-cross2" " pl10-s-la1511" " pl6-s-m248" " pl40-s-cross2"
## [73] " pl39-s-cross2" " pl38-s-cross2" " pl37-s-cross2" " pl36-s-cross2"
## [77] " pl35-s-cross2" " pl34-s-cross2" " pl33-s-cross2" " pl32-s-cross2"
## [81] " pl31-s-cross2" " pl50-s-cross2" " pl49-s-cross2" " pl48-s-cross2"
## [85] " pl9-s-la1511" " pl47-s-cross2" " pl46-s-cross2" " pl45-s-cross2"
## [89] " pl44-s-cross2" " pl43-s-cross2" " pl42-s-cross2" " pl7-s-m248"
## [93] " pl41-s-cross2" " pl59-s-cross2" " pl58-s-cross2" " pl8-s-la1511"
## [97] " pl57-s-cross2" " pl56-s-cross2" " pl55-s-cross2" " pl54-s-cross2"
## [101] " pl53-s-cross2" " pl52-s-cross2" " pl51-s-cross2" " pl72-s-cross2"
## [105] " pl8-s-m248" " pl71-s-cross2" " pl70-s-cross2" " pl69-s-cross2"
## [109] " pl68-s-cross2" " pl67-s-cross2" " pl66-s-cross2" " pl65-s-cross2"
## [113] " pl64-s-cross2" " pl63-s-cross2" " pl62-s-cross2" " pl61-s-cross2"
## [117] " pl42-s-cross1" " pl41-s-cross1" " pl40-s-cross1" " pl39-s-cross1"
## [121] " pl38-s-cross1" " pl10-s-m248" " pl37-s-cross1" " pl36-s-cross1"
## [125] " pl35-s-cross1" " pl34-s-cross1" " pl33-s-cross1" " pl32-s-cross1"
## [129] " pl31-s-cross1" " pl54-s-cross1" " pl53-s-cross1" " pl9-s-m248"
## [133] " pl52-s-cross1" " pl51-s-cross1" " pl50-s-cross1" " pl47-s-cross1"
## [137] " pl48-s-cross1" " pl49-s-cross1" " pl6-s-la1511" " pl43-s-cross1"
## [141] " pl44-s-cross1" " pl45-s-cross1" " pl7-s-la1511" " pl65-s-cross1"
## [145] " pl63-s-cross1" " pl62-s-cross1" " pl61-s-cross1" " pl60-s-cross1"
## [149] " pl59-s-cross1" " pl58-s-cross1" " pl57-s-cross1" " pl56-s-cross1"
## [153] " pl55-s-cross1" " pl72-s-cross1" " pl71-s-cross1" " pl70-s-cross1"
## [157] " pl69-s-cross1" " pl68-s-cross1" " pl67-s-cross1" " pl66-s-cross1"
## [161] " pl15-s-m248" " pl82-s-cross1" " pl81-s-cross1" " pl80-s-cross1"
## [165] " pl79-s-cross1" " pl78-s-cross1" " pl77-s-cross1" " pl76-s-cross1"
## [169] " pl75-s-cross1" " pl74-s-cross1" " pl73-s-cross1" " pl90-s-cross1"
## [173] " pl89-s-cross1" " pl88-s-cross1" " pl87-s-cross1" " pl14-s-la1511"
## [177] " pl86-s-cross1" " pl85-s-cross1" " pl84-s-cross1" " pl83-s-cross1"
## [181] " pl14-s-m248" " pl82-s-cross2" " pl81-s-cross2" " pl80-s-cross2"
## [185] " pl79-s-cross2" " pl78-s-cross2" " pl77-s-cross2" " pl13-s-la1511"
## [189] " pl76-s-cross2" " pl75-s-cross2" " pl74-s-cross2" " pl73-s-cross2"
## [193] " pl13-s-m248" " pl90-s-cross2" " pl89-s-cross2" " pl83-s-cross2"
## [197] " pl84-s-cross2" " pl11-s-m248" " pl85-s-cross2" " pl86-s-cross2"
## [201] " pl11-s-la1511" " pl12-s-m248" " pl87-s-cross2" " pl12-s-LA1511"
## [205] " root_0" " pl15-s-la1511"
unique(MR_all$genotype)
## [1] "la1511" "m248" "cross1" "cross2" "cross" "class2" "LA1511" NA
#it seems that I have one main root that does not have name and I have inconsistency in genotype name as well…..so I can at least use gsub to fix the genotypes….see the below code…but it made everything weired
#MR_all$genotype <- gsub("cross", "cross2",MR_all$genotype)
#unique(MR_all$genotype)
good_stuff <- c("m248", "la1511", "cross1","cross2")
funk <- subset(MR_all, !(MR_all$genotype %in% good_stuff))
funk
MR_all <- subset(MR_all, (MR_all$genotype %in% good_stuff))
unique(MR_all$genotype)
## [1] "la1511" "m248" "cross1" "cross2"
library(ggplot2)
library(ggpubr)
MR_all$genotype<- factor(MR_all$genotype, levels=c("la1511", "m248", "cross1", "cross2"))
histogram_TRS_F2 <- ggdensity(MR_all, x = "TRS",
add = "mean", rug = TRUE,facet.by = "genotype",
color = "genotype", fill = "genotype")
histogram_TRS_F2
histogram_LRno_F2 <- ggdensity(MR_all, x = "LRno",
add = "mean", rug = TRUE, facet.by = "genotype",
color = "genotype", fill = "genotype")
histogram_LRno_F2
colnames(MR_all)
## [1] "image" "root_name" "root"
## [4] "length" "root_order" "insertion_position"
## [7] "insertion_angle" "n_child" "child_density"
## [10] "insertion_first_child" "last_child" "insertion_last_child"
## [13] "LRL" "LRno" "LRangle.avg"
## [16] "LRangle.sd" "genotype" "condition"
## [19] "plate" "TRS" "aLRL"
## [22] "MRpLRL"
histogram_aLRL_F2 <- ggdensity(MR_all, x = "aLRL",
add = "mean", rug = TRUE, facet.by = "genotype",
color = "genotype", fill = "genotype")
histogram_aLRL_F2
histogram_MRL_F2 <- ggdensity(MR_all, x = "length",
add = "mean", rug = TRUE, facet.by = "genotype",
color = "genotype", fill = "genotype")
histogram_MRL_F2
pdf("histogram.TRS.F2.pdf")
plot(histogram_TRS_F2)
dev.off()
## png
## 2
pdf("histogram.LRno.F2.pdf")
plot(histogram_LRno_F2)
dev.off()
## png
## 2
library(cowplot)
##
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggpubr':
##
## get_legend
pdf("Figure_Histogram.pdf", height = 15, width = 12)
plot_grid(histogram_TRS_F2, histogram_LRno_F2, ncol=2,
align = "hv", labels=c("AUTO"),
label_size = 24)
dev.off()
## png
## 2
unique(MR_all$genotype)
## [1] la1511 m248 cross1 cross2
## Levels: la1511 m248 cross1 cross2
TRS_graph <- ggplot(data=MR_all, aes(x= genotype, y=TRS, color = genotype))
TRS_graph <- TRS_graph + geom_boxplot()
#TRS_graph <- TRS_graph + facet_grid(~genotype, scales = "free") + scale_color_manual(values=c("blue","turquoise3", "cyan","maroon3"))
TRS_graph <- TRS_graph + ylab("Total root size (cm)") + xlab("Genotype") + theme(legend.position='none')
TRS_graph
library(ggplot2)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
MR_all$genotype2 <- MR_all$genotype
MR_all$genotype2 <- gsub("cross1", "F2", MR_all$genotype2)
MR_all$genotype2 <- gsub("cross2", "F2", MR_all$genotype2)
MR_all$genotype2 <- factor(MR_all$genotype2, levels = c("la1511", "m248", "F2"))
MR_graph <- ggerrorplot(MR_all, y = "length", x = "genotype2", fill="genotype2", color="genotype2",
desc_stat = "mean_sd", add = "jitter",
add.params = list(color = "darkgray"),
xlab="", ylab="Main Root Length (cm)")
MR_graph <- MR_graph + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
MR_graph
library("ggsci")
MR_all$genotype2 <- MR_all$genotype
MR_all$genotype2 <- gsub("cross1", "F2", MR_all$genotype2)
MR_all$genotype2 <- gsub("cross2", "F2", MR_all$genotype2)
MR_all$genotype2 <- factor(MR_all$genotype2, levels = c("la1511", "m248", "F2"))
LR_graph <- ggscatter(MR_all, y = "LRL", x = "LRno", fill="genotype2", color="genotype2", id = "root_name",
xlab="Lateral root number", ylab="Lateral root length (cm)")
LR_graph <- LR_graph + scale_color_jco()
LR_graph
ggplotly(LR_graph)
aLR_graph <- ggscatter(MR_all, y = "aLRL", x = "LRno", fill="genotype2", color="genotype2", id = "root_name",
xlab="Lateral root number", ylab="Lateral root length (cm)") + geom_hline(yintercept = 2, linetype = "dashed") + geom_vline(xintercept = 10, linetype = "dashed")
aLR_graph <- aLR_graph + scale_color_jco()
aLR_graph
MR_all3 <- subset(MR_all, MR_all$length > 6)
aLR_graph2 <- ggscatter(MR_all3, y = "aLRL", x = "LRno", fill="genotype2", color="genotype2",
xlab="Lateral root number", ylab="Lateral root length (cm)") + geom_hline(yintercept = 1.8, linetype = "dashed") + geom_vline(xintercept = 9.9, linetype = "dashed")
aLR_graph2 <- aLR_graph2 + scale_color_jco()
aLR_graph2
ggplotly(aLR_graph2)
library(plotly)
head(MR_all3)
p <- plot_ly(data = MR_all3, y = ~aLRL, x = ~LRno, fill=~genotype2, color=~genotype2, type = "scatter", mode = "markers", text = ~root_name)
#p <- p + geom_hline(yintercept = 1.8, linetype = "dashed") + geom_vline(xintercept = 9.9, linetype = "dashed")
p
MR_all_F2 <- subset(MR_all, MR_all$genotype2 == "F2")
aLR_graph_pMRL <- ggscatter(MR_all_F2, y = "aLRL", x = "LRno", fill="length", color="length", id = "root_name",
xlab="Lateral root number", ylab="Lateral root length (cm)")
aLR_graph_pMRL