View <- ZN_data ZN_data$Treatment ZN_data$Treatment <- as.factor (ZN_data$Treatment) str(ZN_data$Treatment) TreatmentID <- as.numeric(ZN_data$Treatment) TreatmentID ma <- as.matrix(ZN_data[, 2:50]) # convert to matrix disMatarix <- dist(ma) #Distance Matrix Computation plot(hclust(disMatarix)) rownames(ma) <- c("A0+FI+V1", "A0+PDI+V1", "A0+SDI+V1", "A1+FI+V1", "A1+PDI+V1", "A1+SDI+V1", "A2+FI+V1", "A2+PDI+V1", "A2+SDI+V1", "A0+FI+V2", "A0+PDI+V2", "A0+SDI+V2", "A1+FI+V2", "A1+PDI+V2", "A1+SDI+V2", "A2+FI+V2", "A2+PDI+V2", "A2+SDI+V2", "A0+FI+V3", "A0+PDI+V3", "A0+SDI+V3", "A1+FI+V3", "A1+PDI+V3", "A1+SDI+V3", "A2+FI+V3", "A2+PDI+V3", "A2+SDI+V3") heatmap(ma, scale = "column", RowSideColors = rainbow(7)[ZN_data$Treatment] ) #install.packages("pheatmap") library(pheatmap) ma <- as.matrix(ZN_data[1:27, 2:50]) # convert to matrix row.names(ma) <- row.names(ZN_data[,1]) rownames(ma) <- rownames(ZN_data[, 1]) # assign row names in the matrix pheatmap(ma, scale = "column", clustering_method = "average", # average linkage row.names(ZN_data[,1, drop = FALSE]), # the 1st column as color bar show_rownames = TRUE ) pheatmap(ma, scale = "column", clustering_method = "average", # average linkage annotation_row = ZN_data [,1, drop = FALSE], # the 1st column as color bar show_rownames = TRUE ) library(pheatmap) ma <- as.matrix(ZN_data[, 2:45]) # convert to matrix rownames(ma) <- c("A0+FI+V1", "A0+PDI+V1", "A0+SDI+V1", "A1+FI+V1", "A1+PDI+V1", "A1+SDI+V1", "A2+FI+V1", "A2+PDI+V1", "A2+SDI+V1", "A0+FI+V2", "A0+PDI+V2", "A0+SDI+V2", "A1+FI+V2", "A1+PDI+V2", "A1+SDI+V2", "A2+FI+V2", "A2+PDI+V2", "A2+SDI+V2", "A0+FI+V3", "A0+PDI+V3", "A0+SDI+V3", "A1+FI+V3", "A1+PDI+V3", "A1+SDI+V3", "A2+FI+V3", "A2+PDI+V3", "A2+SDI+V3") pheatmap(ma, scale = "column", clustering_method = "average", # average linkage drop = FALSE, # the 1st column as color bar show_rownames = TRUE ) #1-heatmap x <- ZN_data x <- as.matrix(ZN_data[, 2:50]) rownames(ma) <- c("A0+FI+V1", "A0+PDI+V1", "A0+SDI+V1", "A1+FI+V1", "A1+PDI+V1", "A1+SDI+V1", "A2+FI+V1", "A2+PDI+V1", "A2+SDI+V1", "A0+FI+V2", "A0+PDI+V2", "A0+SDI+V2", "A1+FI+V2", "A1+PDI+V2", "A1+SDI+V2", "A2+FI+V2", "A2+PDI+V2", "A2+SDI+V2", "A0+FI+V3", "A0+PDI+V3", "A0+SDI+V3", "A1+FI+V3", "A1+PDI+V3", "A1+SDI+V3", "A2+FI+V3", "A2+PDI+V3", "A2+SDI+V3") #2 install.packages("gplots") #3-pheatmaps install.packages("pheatmap") library(pheatmap) pheatmap(x, scale = "column", clustering_method = "average", annotation_col = ZN_data[, 1, drop = FALSE], cutree_rows = 6, cutree_cols = 3, show_rownames = FALSE ) max <- cbind(ZN_data [,1], ma) heatmap(ma) ma <- as.matrix(ZN_data[, 2:50]) rownames(ma) <- c("A0+FI+V1", "A0+PDI+V1", "A0+SDI+V1", "A1+FI+V1", "A1+PDI+V1", "A1+SDI+V1", "A2+FI+V1", "A2+PDI+V1", "A2+SDI+V1", "A0+FI+V2", "A0+PDI+V2", "A0+SDI+V2", "A1+FI+V2", "A1+PDI+V2", "A1+SDI+V2", "A2+FI+V2", "A2+PDI+V2", "A2+SDI+V2", "A0+FI+V3", "A0+PDI+V3", "A0+SDI+V3", "A1+FI+V3", "A1+PDI+V3", "A1+SDI+V3", "A2+FI+V3", "A2+PDI+V3", "A2+SDI+V3") ZN_data mat = matrix(rnorm(100), 10) rownames(mat) = paste0("R", 2:27) colnames(mat) = paste0("C", 2:50) library(circlize) col_fun = colorRamp2(c(-2,0,2), c("green", "black", "red")) col_fun(seq(-3, 3)) heatmap(mat, name = "mat", col = col_fun) x <- ZN_data x <- as.matrix(ZN_data[, 2:50]) rownames(ma) <- c("A0+FI+V1", "A0+PDI+V1", "A0+SDI+V1", "A1+FI+V1", "A1+PDI+V1", "A1+SDI+V1", "A2+FI+V1", "A2+PDI+V1", "A2+SDI+V1", "A0+FI+V2", "A0+PDI+V2", "A0+SDI+V2", "A1+FI+V2", "A1+PDI+V2", "A1+SDI+V2", "A2+FI+V2", "A2+PDI+V2", "A2+SDI+V2", "A0+FI+V3", "A0+PDI+V3", "A0+SDI+V3", "A1+FI+V3", "A1+PDI+V3", "A1+SDI+V3", "A2+FI+V3", "A2+PDI+V3", "A2+SDI+V3") heatmap(x, scale ="column") # 2-gplots install.packages("gplots") library(gplots) heatmap.2(x, scale = "column", col = bluered(100),trace = "none") #ggplot2 library(ggplot2) y <- ZN_data library(reshape) y1 <- melt (y) Chord Daigram install.packages("circlize") install.packages("readxl") library("circlize") library("readxl") View <- ZN_data ZN_data$Treatment ZN_data$Treatment <- as.factor (ZN_data$Treatment) str(ZN_data$Treatment) TreatmentID <- as.numeric(ZN_data$Treatment) TreatmentID ma <- as.matrix(ZN_data[, 2:50]) # convert to matrix rownames(ma) <- c("A0+FI+V1", "A0+PDI+V1", "A0+SDI+V1", "A1+FI+V1", "A1+PDI+V1", "A1+SDI+V1", "A2+FI+V1", "A2+PDI+V1", "A2+SDI+V1", "A0+FI+V2", "A0+PDI+V2", "A0+SDI+V2", "A1+FI+V2", "A1+PDI+V2", "A1+SDI+V2", "A2+FI+V2", "A2+PDI+V2", "A2+SDI+V2", "A0+FI+V3", "A0+PDI+V3", "A0+SDI+V3", "A1+FI+V3", "A1+PDI+V3", "A1+SDI+V3", "A2+FI+V3", "A2+PDI+V3", "A2+SDI+V3") chordDiagram(ma) circos.clear() circos.par(start.degree = 0, gap.degree = 2, track.margins = c(-0.1,0.1), points.overflow.par(mar = rep(0,4)) #base plot chordDiagram(x = ma, transparency = 0.10, directional = 1, direction.type= c("arrows"), annotationTrack = "grid", annotationTrackHeight = c(0.01, 0.01), link.arr.type = "big.arrow", link.sort = TRUE, link.largest.ontop = TRUE, scale = TRUE) #assign color to each group of strains col = c(R1="#330033" , R10="#330033" , R19="#330033", R2="#330089" , R11="#330089", R20="#330089" , R3="#FF3300", R12="#FF3300" , R21="#FF3300" , R4="#3399CC", R13="#3399CC", R22= "#3399CC", R5="#FFCC00", R14= "#FFCC00", R23= "#FFCC00", R6= "#006600", R15= "#006600", R24="#006600", R7= "grey", R16= "grey", R25= "grey", R8= "#FF3290", R17= "#FF3290", R26= "#FF3290", R9= "brown", R18= "brown", R27= "brown") # add Text and axis circos.clear() circos.trackPlotRegion( track.index = 1, bg.border = NA, panel.fun = function(x, y) { xlim = get.cell.meta.data("xlim") sector.index = get.cell.meta.data("sector.index") # Add names to sector circos.text( x = mean(xlim), y = 6, labels = sector.index, facing = "clockwise", niceFacing = TRUE, #adj = c(0.5, 0), cex = .5) # Add gradation on axis circos.axis( h = "top", major.at = NULL, minor.ticks = 1, labels.cex = .2, labels.niceFacing = FALSE) } ) Sample_Matrix <- matrix(HI_data, nrow = 45, dimnames = list(c("0 t/ac AB+100% IW+V1","0 t/ac AB+70% IW+V1","0 t/ac AB+50% IW+V1","2 t/ac AB+100% IW+V1", "2 t/ac AB+70% IW+V1", "2 t/ac AB+50% IW+V1", "4 t/ac AB+100% IW+V1", "4 t/ac AB+70% IW+V1", "4 t/ac AB+50% IW+V1", "0 t/ac AB+100% IW+V2", "0 t/ac AB+70% IW+V2", "0 t/ac AB+50% IW+V2", "2 t/ac AB+100% IW+V2", "2 t/ac AB+70% IW+V2","2 t/ac AB+50% IW+V2", "4 t/ac AB+100% IW+V2", "4 t/ac AB+70% IW+V2", "4 t/ac AB+50% IW+V2","0 t/ac AB+100% IW+V3","0 t/ac AB+70% IW+V3","0 t/ac AB+50% IW+V3","2 t/ac AB+100% IW+V3", "2 t/ac AB+70% IW+V3", "2 t/ac AB+50% IW+V3", "4 t/ac AB+100% IW+V3", "4 t/ac AB+70% IW+V3", "4 t/ac AB+50% IW+V3"), c("Chl a V", "Chl a R", "Chl b V", "Chl b R", "T Chl V", "T Chl R","Caro V", "Caro R", "Sug V", "Sug R", "Pro V", "Pro R", "RWC V", "RWC R", "Ear Len", "Ear Wt", "T NG", "TGW", "RFW", "SFW", "LFW", "RDW", "SDW", "LDW", "SL", "RL")) chordDiagram(Sample_Matrix) circos.clear() #Color the links #convert the table to a martix data <- as.matrix(data) #assign color to each group of strains col = c(R1="#330033" , R10="#330033" , R19="#330033", R2="#330089" , R11="#330089", R20="#330089" , R3="#FF3300", R12="#FF3300" , R21="#FF3300" , R4="#3399CC",R13="#3399CC", R22= "#3399CC",R5="#FFCC00", R14= "#FFCC00", R23= "#FFCC00", R6="#006600", R15="#006600", R24"#006600", R7= "grey", R16= "grey", R25= "grey", R8= "#FF3290", R17= "#FF3290",R26= "#FF3290",R9= "brown", R18= "brown", R27= "brown" #create a chord diagram but without labeling chordDiagram(HI_data, grid.col = col, annotationTrack = "grid", preAllocateTracks = 1) #add the labels and axis circos.trackPlotRegion(track.index = 2, panel.fun = function(x, y) { xlim = get.cell.meta.data("xlim") ylim = get.cell.meta.data("ylim") sector.name = get.cell.meta.data("sector.index") #print labels circos.text(mean(xlim), ylim[1] + 2.5, sector.name, facing = "clockwise", niceFacing = TRUE, adj = c(0, 0.5), cex=0.6) #print axis circos.axis(h = "top", labels.cex = 0.5, major.tick.percentage = 0.2, sector.index = sector.name, track.index = 2) }, bg.border = NA) #saving the plot (high definition) dev.copy(jpeg,'plot.png', width=8, height=8, units="in", res=500) dev.off() ...................................................................... rm(list=ls()) install.packages("multcompView") install.packages("ggpubr") library(tidyverse) library(car) library(emmeans) library(dplyr) library(ggplot2) library(multcompView) library(dplyr) data <- read.csv("D:\\botany\\Copy of experimet_data-2.csv",header =T) View <- AN_data Amendment <- factor(AN_data$Amendment, levels = c("0T", "5%", "10T")) Drought <- factor(AN_data$Drought, levels = c("100", "70", "50")) Crop <- factor(AN_data$Crop, levels = c("Maize", "Sunflower", "Canola")) Y1=AN_data$`Proline content` aov_result1 <- aov(Y1 ~ Amendment * Drought * Crop, AN_data=AN_data) summary(aov_result1) tukey_result <- TukeyHSD(aov_result1) cld=multcompLetters4(aov_result1,tukey_result) cld_letters <- cld$`Amendment:Drought:Crop`$Letters agg_data <- AN_data %>% group_by(Amendment, Drought, Crop) %>% summarise( mean_Y1 = mean(`Proline content`, na.rm = TRUE), se_Y1 = sd(`Proline content`, na.rm = TRUE) / sqrt(n()), .groups = 'drop' # Ungroup to prevent grouping issues later ) cld_df <- data.frame(Amendment = rep(unique(agg_data$Amendment), times = length(unique(agg_data$Drought)) * length(unique(agg_data$Crop))), Drought = rep(rep(unique(agg_data$Drought), each = length(unique(agg_data$Crop))), times = length(unique(agg_data$Amendment))), Crop = rep(unique(agg_data$Crop), times = length(unique(agg_data$Drought)) * length(unique(agg_data$Amendment))), letters = unlist(cld_letters) ) agg_data <- agg_data %>% left_join(cld_df, by = c("Amendment", "Drought", "Crop")) p <- ggplot(agg_data, aes(x = Concentration, y = mean_Y1, fill = Drought)) + geom_bar(stat = "identity", position = position_dodge(0.9), width = 0.8) + geom_errorbar(aes(ymin = mean_Y1 - se_Y1, ymax = mean_Y1 + se_Y1), position = position_dodge(0.9), width = 0.25) + facet_wrap(~ Mode) + labs(title = "Mean Shoot Length by Mode, Drought, and Concentration", x = "Concentration", y = "Mean Shoot Length", fill = "Drought") + theme_minimal() + theme(axis.text.x = element_text(size = 8, angle = 45, hjust = 1)) + geom_text(aes(label = letters, y = mean_Y1 + se_Y1 + 0.2), position = position_dodge(0.9), vjust = -0.5, size = 3, color = "black") print(p)