-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sungchan Oh
committed
Jul 10, 2024
1 parent
d301e1c
commit 7cffa02
Showing
4 changed files
with
194 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
library(dplyr) | ||
library(ggplot2) | ||
|
||
|
||
# File paths to Input and output data | ||
path.rpt <- ("./rpt_no_public.csv") | ||
path.plot.overall <- ("./rpt_overall.png") | ||
path.plot.sideall <- ("./rpt_sideall.png") | ||
|
||
|
||
|
||
|
||
|
||
# Load repeatability results | ||
df.rpt <- read.csv(path.rpt) | ||
|
||
# Exclude results with NA | ||
df.rpt <- df.rpt[which(!is.na(df.rpt$rpt) & is.finite(df.rpt$rpt)), ] | ||
|
||
# Select data with View==SideAll | ||
df.rpt.sideall <- df.rpt[which(df.rpt$View=="SideAll"),] | ||
|
||
# Simplify attributes under df.rpt$View | ||
df.rpt$View <- replace(df.rpt$View, | ||
df.rpt$View %in% c("SideAll", "SideAverage"), | ||
"Side") | ||
|
||
# Plot results (overall data) | ||
p1 <- ggplot(df.rpt, aes(x=View, y=rpt)) + geom_boxplot() + | ||
facet_grid(rows=vars(GROWTH_STAGE), cols=vars(TREATMENT)) + | ||
labs(y = "Repeatability, Input: all RGB and HSI data") | ||
png(path.plot.overall) | ||
print(p1) | ||
dev.off() | ||
|
||
# Plot results (sideall data) | ||
df.rpt.sideall$frame_nr <- as.factor(df.rpt.sideall$frame_nr) | ||
p2 <- ggplot(df.rpt.sideall, aes(x=frame_nr, y=rpt)) + geom_boxplot() + | ||
facet_grid(rows=vars(GROWTH_STAGE), cols=vars(TREATMENT)) + | ||
labs(y = "Repeatability, Input: RGB data from different vewing angles") | ||
png(path.plot.sideall) | ||
print(p2) | ||
dev.off() | ||
|
||
|
||
|
||
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,97 @@ | ||
library(dplyr) | ||
library(ggplot2) | ||
|
||
# TODO | ||
# calc rpt without public hybrid | ||
# order hybrid a b c ... | ||
# yaxis label <- variable | ||
|
||
|
||
# Input long format data | ||
|
||
|
||
# Path to input and output data | ||
path.rgb.long <- ("./df_rgb_long.csv") | ||
path.hsi.long <- ("./df_hsi_long.csv") | ||
path.rpt <- ("./rpt.csv") | ||
path.rpt <- ("./rpt_no_public.csv") | ||
|
||
# Variables demonstrating highest to n-th highest repeatability will be displayed | ||
# in each combination of (TREATMENT, GROWTH_STAGE) | ||
n <- 5 | ||
|
||
# List of varieties to be excluded, if any; otherwise, exclude.variety as "c()" | ||
exclude.variety <-c("P1", "P2", "P3", "P4") | ||
|
||
|
||
# Load RGB and HSI data in long format | ||
message("Loading data...") | ||
df.rgb <- read.csv(path.rgb.long) | ||
df.hsi <- read.csv(path.hsi.long) | ||
df.rpt <- read.csv(path.rpt) | ||
|
||
# Combine RGB and HSI data | ||
df <- rbind(df.rgb, df.hsi) | ||
|
||
|
||
|
||
# Sort repeatability by desending order | ||
message("Sorting repeatability data...") | ||
df.rpt <- df.rpt[!is.na(df.rpt$repeatability),] | ||
df.rpt.sort <- df.rpt[order(df.rpt$repeatability, decreasing=T), ] | ||
|
||
|
||
|
||
|
||
n <- 10 | ||
for (i in seq(1,10)){ | ||
row <- df.rpt.sort[i,] | ||
df.temp <- df[which(df$TREATMENT==row$TREATMENT & | ||
df$GROWTH_STAGE==row$GROWTH_STAGE & | ||
df$View==row$View & | ||
df$frame_nr==row$frame_nr & | ||
df$variable==row$variable), ] | ||
p = ggplot(df.temp, aes(x=VARIETY, y=value)) + | ||
geom_boxplot() | ||
path.plot <- paste0('./variance_', i, '_', row$TREATMENT, '_', row$GROWTH_STAGE, '_', row$View, '_', row$frame_nr, '_', row$variable, '.png') | ||
png(path.plot) | ||
print(p) | ||
dev.off() | ||
# Load RGB and HSI data in long format | ||
message("Loading data...") | ||
df.rgb <- read.csv(path.rgb.long) | ||
df.hsi <- read.csv(path.hsi.long) | ||
df.rpt <- read.csv(path.rpt) | ||
|
||
# Exclude varieties, as needed | ||
if (length(exclude.variety)>0){ | ||
df.rgb <- df.rgb %>% filter(!VARIETY %in% exclude.variety) | ||
df.hsi <- df.hsi %>% filter(!VARIETY %in% exclude.variety) | ||
} | ||
|
||
# Combine RGB and HSI data | ||
df <- rbind(df.rgb, df.hsi) | ||
|
||
# Simplify attributes under df.rpt$View | ||
df.rpt$View <- replace(df.rpt$View, | ||
df.rpt$View %in% c("SideAll", "SideAverage"), | ||
"Side") | ||
df$View <- replace(df$View, | ||
df$View %in% c("SideAll", "SideAverage"), | ||
"Side") | ||
|
||
# Choose valid repeatability measurements | ||
df.rpt <- df.rpt[!is.na(df.rpt$rpt),] | ||
|
||
for (treatment in unique(df.rpt$TREATMENT)){ | ||
for (growth.stage in unique(df.rpt$GROWTH_STAGE)){ | ||
print(paste0("Generating plots for ", | ||
treatment, ", ", growth.stage, " case...")) | ||
|
||
# Subset data by treatment and growth stage | ||
df.rpt.temp <- df.rpt[which(df.rpt$TREATMENT==treatment & | ||
df.rpt$GROWTH_STAGE==growth.stage), ] | ||
df.rpt.temp <- df.rpt.temp[order(df.rpt.temp$rpt, decreasing=T), ] | ||
|
||
|
||
for (i in seq(1, n)){ | ||
# Gather measurements from a variable with n-th highest repeatability | ||
row <- df.rpt.temp[i,] | ||
df.temp <- df[which(df$TREATMENT==row$TREATMENT & | ||
df$GROWTH_STAGE==row$GROWTH_STAGE & | ||
df$View==row$View & | ||
df$frame_nr==row$frame_nr & | ||
df$variable==row$variable), ] | ||
# Draw box plot | ||
p = ggplot(df.temp, aes(x=VARIETY, y=value)) + | ||
ggtitle(paste0("Repeatability=", round(row$rpt, 3))) + | ||
geom_boxplot() + | ||
ylab(paste("Variable: ", | ||
row$TREATMENT, row$GROWTH_STAGE, | ||
row$View, row$frame_nr, row$variable, | ||
sep='_')) | ||
path.plot <- paste0(paste('./variance', | ||
row$TREATMENT, row$GROWTH_STAGE, | ||
i, | ||
row$View, row$frame_nr, row$variable, | ||
sep='_'), '.png') | ||
# Save plot | ||
png(path.plot) | ||
print(p) | ||
dev.off() | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters