Skip to content

Check against hard-coded pigment names is fragile #62

Description

@7yl4r

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions