aboutsummaryrefslogtreecommitdiff
path: root/wqflask/wqflask
diff options
context:
space:
mode:
authorZachary Sloan2013-10-08 12:13:56 -0500
committerZachary Sloan2013-10-08 12:13:56 -0500
commit3325184b1dd310619626dd31852ab84cae6dc7fc (patch)
treebf0d3893e25c14094066611f5e7d075d8b0fd092 /wqflask/wqflask
parent4c37e3962d6f34a935ea23511e5b760be4208474 (diff)
downloadgenenetwork2-3325184b1dd310619626dd31852ab84cae6dc7fc.tar.gz
Did some work with interval mapping page; will use qtl reaper to do
the mapping, since it is reliable/fast and avoids us having to rewrite from scratch using something like r/qtl
Diffstat (limited to 'wqflask/wqflask')
-rw-r--r--wqflask/wqflask/interval_mapping/interval_mapping.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/wqflask/wqflask/interval_mapping/interval_mapping.py b/wqflask/wqflask/interval_mapping/interval_mapping.py
index 48e8018e..5d660224 100644
--- a/wqflask/wqflask/interval_mapping/interval_mapping.py
+++ b/wqflask/wqflask/interval_mapping/interval_mapping.py
@@ -12,6 +12,7 @@ import collections
import numpy as np
from scipy import linalg
+import rpy2.robjects
import simplejson as json
@@ -83,6 +84,28 @@ class IntervalMapping(object):
"""Generates qtl results for plotting interval map"""
self.dataset.group.get_markers()
+ self.dataset.read_genotype_file()
+
+ samples, values, variances = self.trait.export_informative()
+ if self.control_locus:
+ if self.weighted_regression:
+ qtl_result = self.dataset.genotype.regression(strains = samples,
+ trait = values,
+ variance = variances,
+ control = self.control_locus)
+ else:
+ qtl_result = self.dataset.genotype.regression(strains = samples,
+ trait = values,
+ control = self.control_locus)
+ else:
+ if self.weighted_regression:
+ qtl_result = self.dataset.genotype.regression(strains = samples,
+ trait = values,
+ variance = variances)
+ else:
+ qtl_result = self.dataset.genotype.regression(strains = samples,
+ trait = values)
+
pheno_vector = np.array([val == "x" and np.nan or float(val) for val in self.vals])
@@ -108,6 +131,36 @@ class IntervalMapping(object):
self.qtl_results = self.dataset.group.markers.markers
+ #def gen_qtl_results_2(self, tempdata):
+ # """Generates qtl results for plotting interval map"""
+ #
+ # self.dataset.group.get_markers()
+ # self.dataset.read_genotype_file()
+ #
+ # pheno_vector = np.array([val == "x" and np.nan or float(val) for val in self.vals])
+ #
+ # #if self.dataset.group.species == "human":
+ # # p_values, t_stats = self.gen_human_results(pheno_vector, tempdata)
+ # #else:
+ # genotype_data = [marker['genotypes'] for marker in self.dataset.group.markers.markers]
+ #
+ # no_val_samples = self.identify_empty_samples()
+ # trimmed_genotype_data = self.trim_genotypes(genotype_data, no_val_samples)
+ #
+ # genotype_matrix = np.array(trimmed_genotype_data).T
+ #
+ # t_stats, p_values = lmm.run(
+ # pheno_vector,
+ # genotype_matrix,
+ # restricted_max_likelihood=True,
+ # refit=False,
+ # temp_data=tempdata
+ # )
+ #
+ # self.dataset.group.markers.add_pvalues(p_values)
+ #
+ # self.qtl_results = self.dataset.group.markers.markers
+
def identify_empty_samples(self):
no_val_samples = []