The following check will not work if unusual pigment names are used.
|
# ---- Matrix normalization helpers ---- |
|
# Uploaded files may include ID columns instead of rownames. |
|
# These helpers standardize matrices before rendering. |
|
|
|
normalize_samples <- function(df){ |
|
first_name <- colnames(df)[1] |
|
|
|
# If first column does not look like a pigment, treat it as sample IDs |
|
pigment_like <- grepl("Per|Fuco|Pra|Zea|Tchla|Chl|X19", first_name) |
|
|
|
if(!pigment_like){ |
|
ids <- make.unique(as.character(df[[1]])) |
|
rownames(df) <- ids |
|
df <- df[, -1, drop = FALSE] |
|
} |
|
df |
|
} |
|
|
|
|
|
normalize_taxa <- function(df){ |
|
if(ncol(df) == 0) return(df) |
|
first_name <- colnames(df)[1] |
|
|
|
# Same logic as samples: detect whether the first column holds taxa names |
|
pigment_like <- grepl("Per|Fuco|Pra|Zea|Tchla|Chl|X19", first_name) |
|
|
|
if(!pigment_like){ |
|
ids <- make.unique(as.character(df[[1]])) |
|
rownames(df) <- ids |
|
df <- df[, -1, drop = FALSE] |
|
} |
|
df |
|
} |
Previously this was a check if the column was characters.
I wonder if these checks are entirely necessary. We want the phytoclass library to be handling warnings and error checking rather than the GUI.
The following check will not work if unusual pigment names are used.
phytoclass-shiny-gui/app/server.R
Lines 55 to 87 in 1ea5610
Previously this was a check if the column was characters.
I wonder if these checks are entirely necessary. We want the phytoclass library to be handling warnings and error checking rather than the GUI.