-
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 30, 2024
1 parent
c26f5a9
commit 54df941
Showing
5 changed files
with
185 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ | |
# Output figures | ||
*.png | ||
|
||
# Animated gif | ||
*.gif | ||
|
||
# History files | ||
.Rhistory | ||
.Rapp.history | ||
|
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
File renamed without changes.
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,74 @@ | ||
|
||
library(dplyr) | ||
path.xray.out <- './df_xray_long.csv' | ||
|
||
# Columns to be retrieved from rgb data and added to xray data | ||
col.add <- c('POT_BARCODE', 'TREATMENT', 'VARIETY', 'DFP', 'GROWTH_STAGE') | ||
|
||
# File path to rgb dataframe to retrieve TREATMENT, VARIETY, DFP, GROWTH_STAGE | ||
path.rgb.long <- './df_rgb_long.csv' | ||
|
||
# File path pattern containing xray results | ||
pattern <- paste0('/depot/smarterag/data/XRAY/', | ||
'Experiment_Bayer2/', | ||
'Experiment_*/', | ||
'kimimaro_out_200/', | ||
'*.txt') | ||
|
||
# Get file paths containing individual phenotyping results | ||
files <- Sys.glob(file.path(pattern)) | ||
|
||
# Open individual files and merge them into a dataframe | ||
xray <- data.frame() | ||
for (f in files){ | ||
tmp <- read.csv(f) | ||
xray <- rbind(xray, tmp) | ||
} | ||
|
||
|
||
|
||
|
||
# Change column names | ||
names(xray)[names(xray)=='experiment_ID'] <- 'EXP ID' | ||
names(xray)[names(xray)=='plant_ID'] <- 'POT_BARCODE' | ||
names(xray)[names(xray)=='RESOLUTION'] <- 'View' | ||
|
||
# Remove unnecessary columns | ||
xray <- subset(xray, select=-c(pot_height)) | ||
|
||
|
||
|
||
|
||
# Load rgb dataframe (long format table) | ||
rgb.long <- read.csv(path.rgb.long) | ||
|
||
# Get attributes per each POT_BARCODE (TREATMENT, VARIEY, DFP, GRWOTH_STAGE) | ||
attributes <- rgb.long %>% | ||
group_by(POT_BARCODE) %>% | ||
summarise(TREATMENT=names(which.max(table(TREATMENT))), | ||
VARIETY=names(which.max(table(VARIETY))), | ||
DFP=names(which.max(table(DFP))), | ||
GROWTH_STAGE=names(which.max(table(GROWTH_STAGE)))) %>% | ||
|
||
ungroup() | ||
|
||
# Add more attributes for consistency with rgb and hsi data | ||
#attributes$SCAN_TIME <- -1 | ||
#attributes$SCAN_DATE <- -1 | ||
attributes$frame_nr <- -1 | ||
|
||
# Add the attributes to xray data | ||
xray <- left_join(xray, attributes, by = 'POT_BARCODE') | ||
|
||
# Reshape xray dataframe | ||
id.vars.xray <- c("EXP ID", "POT_BARCODE", "VARIETY", "TREATMENT", "DFP", | ||
"GROWTH_STAGE", "View", "frame_nr") | ||
|
||
xray.long <- reshape2::melt(xray, id.vars = id.vars.xray, | ||
variable.name = "variable") | ||
|
||
# Export dataframe | ||
write.csv(xray.long, path.xray.out, row.names=F) | ||
|
||
|
||
# EOF |