@@ -142,6 +142,10 @@ create.pgs.density.plot <- function(
142142 if (! all(pgs.columns %in% colnames(pgs.data ))) {
143143 stop(' pgs.columns must be a subset of the column names in pgs.data, please check your input' );
144144 }
145+ # If user-provided pgs columns, check that they are numeric
146+ if (! all(sapply(pgs.data [, pgs.columns , drop = FALSE ], is.numeric ))) {
147+ stop(' All columns specified in pgs.columns must be numeric.' );
148+ }
145149 } else {
146150 # If no pgs columns provided, default to recognized PGS columns
147151 recognized.pgs.colnames <- c(' PGS' , ' PGS.with.replaced.missing' , ' PGS.with.normalized.missing' );
@@ -480,6 +484,10 @@ create.pgs.boxplot <- function(
480484 if (! all(pgs.columns %in% colnames(pgs.data ))) {
481485 stop(' pgs.columns must be a subset of the column names in pgs.data, please check your input' );
482486 }
487+ # If user-provided pgs columns, check that they are numeric
488+ if (! all(sapply(pgs.data [, pgs.columns , drop = FALSE ], is.numeric ))) {
489+ stop(' All columns specified in pgs.columns must be numeric.' );
490+ }
483491 } else {
484492 # If no pgs columns provided, default to recognized PGS columns
485493 recognized.pgs.colnames <- c(' PGS' , ' PGS.with.replaced.missing' , ' PGS.with.normalized.missing' );
@@ -796,6 +804,10 @@ create.pgs.with.continuous.phenotype.plot <- function(
796804 if (! all(pgs.columns %in% colnames(pgs.data ))) {
797805 stop(' pgs.columns must be a subset of the column names in pgs.data, please check your input' );
798806 }
807+ # If user-provided pgs columns, check that they are numeric
808+ if (! all(sapply(pgs.data [, pgs.columns , drop = FALSE ], is.numeric ))) {
809+ stop(' All columns specified in pgs.columns must be numeric.' );
810+ }
799811 } else {
800812 # If no pgs columns provided, default to recognized PGS columns
801813 recognized.pgs.colnames <- c(' PGS' , ' PGS.with.replaced.missing' , ' PGS.with.normalized.missing' );
0 commit comments