From dcd39f9dd123d091218fec5e5410490e58e5b3f4 Mon Sep 17 00:00:00 2001 From: Paul Staab Date: Thu, 22 Oct 2015 13:54:35 +0200 Subject: [PATCH] fix ihh return matrix without snps --- R/sumstat_ihh.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/sumstat_ihh.R b/R/sumstat_ihh.R index 4e176f7..7408f4b 100644 --- a/R/sumstat_ihh.R +++ b/R/sumstat_ihh.R @@ -9,8 +9,7 @@ stat_ihh_class <- R6Class("stat_ihh", inherit = sumstat_class, population = NULL, max_snps = Inf, use_ihs = FALSE, - empty_matrix = matrix(0, 0, 3, - dimnames = list(NULL, c("IHHa", "IHHd", "IES"))), + empty_matrix = NULL, get_snp = function(positions, locus, model) { if (is.na(private$position)) return(seq(along = positions)) pos <- conv_middle_to_trio_pos(private$position, model, locus, @@ -29,6 +28,14 @@ stat_ihh_class <- R6Class("stat_ihh", inherit = sumstat_class, private$position <- position private$max_snps <- max_snps private$use_ihs <- calc_ihs + if (calc_ihs) { + private$empty_matrix <- + matrix(0, 0, 4, dimnames = + list(NULL, c("IHHa", "IHHd", "IES", "iHS"))) + } else { + private$empty_matrix <- + matrix(0, 0, 3, dimnames = list(NULL, c("IHHa", "IHHd", "IES"))) + } super$initialize(name) }, calculate = function(seg_sites, trees, files, model) {