From 90cd6a9df350c197185c638729299959ac54d3b0 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Wed, 18 Mar 2015 17:34:07 +0100 Subject: Some more minor code/comment updates, making code a little shorter --- wqflask/wqflask/marker_regression/marker_regression.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 5ddae0a1..60bc721e 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -314,20 +314,18 @@ class MarkerRegression(object): def create_covariates(self, cross): ro.globalenv["the_cross"] = cross - ro.r('genotypes <- pull.geno(the_cross)') # Get genotype matrix - userinputS = self.control.replace(" ", "").split(",") # TODO sanitize user input !!! never trust a user - covariate_names = ', '.join('"{0}"'.format(w) for w in userinputS) - print(covariate_names) - ro.r('covariates <- genotypes[,c(' + covariate_names + ')]') # get covariate matrix, - print("COVARIATES:", ro.r["covariates"]) + ro.r('genotypes <- pull.geno(the_cross)') # Get the genotype matrix + userinputS = self.control.replace(" ", "").split(",") # TODO sanitize user input, Never Ever trust a user + covariate_names = ', '.join('"{0}"'.format(w) for w in userinputS) + print("Marker names of selected covariates:", covariate_names) + ro.r('covariates <- genotypes[,c(' + covariate_names + ')]') # Get the covariate matrix by using the marker name as index to the genotype file + print("R/qtl matrix of covariates:", ro.r["covariates"]) return ro.r["covariates"] def sanitize_rqtl_phenotype(self): pheno_as_string = "c(" - null_pos = [] for i, val in enumerate(self.vals): if val == "x": - null_pos.append(i) if i < (len(self.vals) - 1): pheno_as_string += "NA," else: @@ -342,7 +340,7 @@ class MarkerRegression(object): def process_rqtl_results(self, result): # TODO: how to make this a one liner and not copy the stuff in a loop qtl_results = [] - + output = [tuple([result[j][i] for j in range(result.ncol)]) for i in range(result.nrow)] print("R/qtl scanone output:", output) -- cgit v1.2.3