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"
bsa_1st<- read.csv("F2-d9-1st-batch.csv")
bsa_1st
library(readr)
library(dplyr)
##
## Attaching package: 'dplyr'
## 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_1st, bsa_1st$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_1st, bsa_1st$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] 69
for(i in 2:69){
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 of the number for the dim(MR_data_noChild)is pretty low!!!! 4
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] 69 16
dim(MR_data_noChild)
## [1] 4 16
dim(MR_all)
## [1] 73 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] 73 16
for(i in 1:73){
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] 70
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" " root_0"
unique(MR_all$genotype)
## [1] "la1511" "m248" "cross1" "cross2" "cross" "class2" 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
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 + rremove("legend") + stat_compare_means(method="t.test", ref.group = "noaba_c",
#label = "p.signif", hide.ns = T)
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)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.