about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/rqtl_wrapper.R14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/rqtl_wrapper.R b/scripts/rqtl_wrapper.R
index a2b4403..5c67d88 100644
--- a/scripts/rqtl_wrapper.R
+++ b/scripts/rqtl_wrapper.R
@@ -179,6 +179,20 @@ verbose_print('Generating cross object\n')
 scale_col <- if (toupper(opt$scale) == "CM") "cM" else "Mb"
 cross_object = geno_to_csvr(geno_file, trait_names, trait_vals, cross_file, type, mapping_scale = scale_col)
 
+# Fail loudly when the phenotype and genotype disagree about how many
+# individuals there are. The cross file format has no per-sample name
+# matching (see README), so the only thing that ties the two together is
+# position: a trait covering 9 strains scanned against a 6-individual
+# cross otherwise comes back with a full, plausible-looking set of LOD
+# scores that belong to nobody. (GeneNetwork3's copy of this script has
+# the same hole.)
+if (length(sample_names) != nind(cross_object)) {
+  stop(sprintf(paste("The phenotype file has %d samples but the genotype file has %d",
+                     "individuals. Values are matched to individuals by position, so the",
+                     "two must be one for one, in the genotype file's column order."),
+               length(sample_names), nind(cross_object)), call.=FALSE)
+}
+
 # Calculate genotype probabilities
 if (!is.null(opt$pairscan)) {
   verbose_print('Calculating genotype probabilities for pair-scan\n')