nasa / GeneLab_Data_Processing

60 stars 42 forks source link

[Microarray] Unintentional renaming of columns causes issues later in selection of columns #97

Open cyouh95 opened 2 months ago

cyouh95 commented 2 months ago

Description

The following error occurred when rendering Affymetrix.qmd for one dataset:

Error in (function (cond)  : 
    error in evaluating the argument 'x' in selecting a method for function 'as.data.frame': Problem while computing `Group.Mean_(1G) = rowMeans(dplyr::select(.,
  all_of(current_samples)))`.
  Caused by error:
  ! error in evaluating the argument 'x' in selecting a method for function 'rowMeans': Problem while evaluating `all_of(current_samples)`.

In this particular dataset, some columns were unintentionally renamed because they happen to contain the substring that's being replaced (for other columns), causing this error when trying to select them later on.

Solution

Be more explicit about which columns we want to rename using rename_with() here in Affymetrix.qmd:

df_interim <- df_interim %>% dplyr::rename_with(reformat_names, .cols = matches('\\.condition'), group_name_mapping = design_data$mapping)

The same can be done here for Agile1CMP.qmd to prevent something similar from happening in the future:

df_interim <- df_interim %>% dplyr::rename_with(reformat_names, .cols = matches('\\.condition|^Genes\\.'), group_name_mapping = design_data$mapping)