aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2023-02-23 18:26:34 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2023-02-23 18:26:34 +0100
commit5a40437e5c2a6dd4650f640c819819df3d1dbdac (patch)
tree8dcb2da468e9e1f1b5dfdf209f3b182a1a1acc27
parent9d6e7920f93c4a2da75ecf053ca2691b91dbafe8 (diff)
Basic check if covariate data are usable
-rw-r--r--R/read_spreadsheet.R15
1 files changed, 11 insertions, 4 deletions
diff --git a/R/read_spreadsheet.R b/R/read_spreadsheet.R
index 7ad09c3e..1c5508da 100644
--- a/R/read_spreadsheet.R
+++ b/R/read_spreadsheet.R
@@ -101,13 +101,20 @@ read_spreadsheet <- function(path, valid_datasets = "all",
# Get covariates
covariates_raw <- readxl::read_excel(path, sheet = "Covariates")
covariates <- as.data.frame(covariates_raw[4:ncol(covariates_raw)])
- rownames(covariates) <- covariates_raw[[1]]
- covariates <- covariates[which(colnames(covariates) != "Remarks")]
+ nocov <- setdiff(groups, covariates_raw[[1]])
+ if (length(nocov) > 0) {
+ message("Did not find covariate data for ", paste(nocov, collapse = ", "))
+ message("Not returning covariate data")
+ attr(ds, "covariates") <- NULL
+ } else {
+ rownames(covariates) <- covariates_raw[[1]]
+ covariates <- covariates[which(colnames(covariates) != "Remarks")]
+ # Attach covariate data if available
+ attr(ds, "covariates") <- covariates[groups, , drop = FALSE]
+ }
# Attach the compound list to support automatic model building
attr(ds, "compounds") <- as.data.frame(compounds)
- # Attach covariate data
- attr(ds, "covariates") <- covariates[groups, , drop = FALSE]
return(ds)
}

Contact - Imprint