From 8f5c45c64d1a62d0bab61abd09698f7bd0461500 Mon Sep 17 00:00:00 2001 From: jeffersonfparil Date: Fri, 26 Jul 2024 08:47:10 +1000 Subject: [PATCH] adding input validation for phenotype data in geno+pheno merge --- R/io.R | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/R/io.R b/R/io.R index 66c4909..1027166 100644 --- a/R/io.R +++ b/R/io.R @@ -2310,6 +2310,23 @@ fn_merge_genotype_and_phenotype = function(G, list_pheno, COVAR=NULL, verbose=FA print("### Merging genotype and phenotype data ###") print("###########################################") } + ### Check list_pheno + if (sum(is.na(list_pheno$y))==length(list_pheno$y)) { + error = methods::new("gpError", + code=284, + message=paste0( + "Error in io::fn_merge_genotype_and_phenotype(...). ", + "All phenotype data are missing.")) + return(error) + } + if (length(names(list_pheno$y)) < length(list_pheno$y)) { + error = methods::new("gpError", + code=285, + message=paste0( + "Error in io::fn_merge_genotype_and_phenotype(...). ", + "Phenotype data are missing names.")) + return(error) + } ### All samples with genotype data will be included and samples without phenotype data will be set to NA (all.x=TRUE) ### Samples with phenotype but without genotype data are omitted. M = merge(