about summary refs log tree commit diff
path: root/wqflask/wqflask
diff options
context:
space:
mode:
authorzsloan2016-05-18 20:06:41 +0000
committerzsloan2016-05-18 20:06:41 +0000
commitf8c89f7c24cbfcffdafd12ef2087f4de598ed4bd (patch)
treeca233c2f08151377de161a616e69031d557ff808 /wqflask/wqflask
parente36ffce0d972334b07ee91b817fc3f30ed3598c4 (diff)
parenta8945cc625f12e9cf733f469426bf0e4b8e83647 (diff)
downloadgenenetwork2-f8c89f7c24cbfcffdafd12ef2087f4de598ed4bd.tar.gz
Merge branch 'staging' of https://github.com/genenetwork/genenetwork2
Diffstat (limited to 'wqflask/wqflask')
-rwxr-xr-xwqflask/wqflask/correlation/show_corr_results.py14
-rwxr-xr-xwqflask/wqflask/correlation_matrix/show_corr_matrix.py1
-rwxr-xr-xwqflask/wqflask/ctl/__init__.py0
-rw-r--r--wqflask/wqflask/ctl/ctl_analysis.py194
-rwxr-xr-xwqflask/wqflask/database.py5
-rw-r--r--wqflask/wqflask/heatmap/heatmap.py7
-rwxr-xr-xwqflask/wqflask/interval_analyst/IntervalAnalystPage.py138
-rwxr-xr-xwqflask/wqflask/marker_regression/MarkerRegressionPage.py10
-rw-r--r--wqflask/wqflask/marker_regression/gemma_mapping.py11
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression.py87
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression_gn1.py132
-rwxr-xr-xwqflask/wqflask/search_results.py3
-rwxr-xr-xwqflask/wqflask/show_trait/show_trait.py13
l---------wqflask/wqflask/static/css1
-rw-r--r--wqflask/wqflask/static/dbdoc/TODO.md1
l---------wqflask/wqflask/static/images1
l---------wqflask/wqflask/static/javascript1
-rwxr-xr-xwqflask/wqflask/static/new/css/corr_matrix.css2
-rwxr-xr-xwqflask/wqflask/templates/base.html2
-rwxr-xr-xwqflask/wqflask/templates/collections/view.html12
-rw-r--r--wqflask/wqflask/templates/ctl_results.html47
-rw-r--r--wqflask/wqflask/templates/ctl_setup.html65
-rwxr-xr-xwqflask/wqflask/templates/index_page.html2
-rw-r--r--wqflask/wqflask/templates/marker_regression_gn1.html4
-rw-r--r--wqflask/wqflask/templates/wgcna_setup.html18
-rw-r--r--wqflask/wqflask/views.py27
-rw-r--r--wqflask/wqflask/wgcna/wgcna_analysis.py6
27 files changed, 544 insertions, 260 deletions
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index 98596ca4..dd661092 100755
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -708,13 +708,11 @@ class CorrelationResults(object):
         
         for sample in sample_names:
             if sample not in excluded_samples:
-                value = start_vars['value:' + sample]
-                if value.strip().lower() == 'x':
-                    self.sample_data[str(sample)] = None
-                else:
-                    self.sample_data[str(sample)] = float(value)
-
-
+                # print("Looking for",sample,"in",start_vars)
+                value = start_vars.get('value:' + sample)
+                if value:
+                    if not value.strip().lower() == 'x':
+                        self.sample_data[str(sample)] = float(value)
 
     ##XZ, 12/16/2008: the input geneid is of mouse type
     #def checkForLitInfo(self,geneId):
@@ -942,7 +940,7 @@ class CorrelationResults(object):
                 use_tissue_corr = True
 
             DatabaseFileName = self.getFileName( target_db_name=self.target_db_name )
-            datasetFile = open(webqtlConfig.TEXTDIR+DatabaseFileName,'r')
+            datasetFile = open(webqtlConfig.CACHEDIR+DatabaseFileName,'r')
 
             #XZ, 01/08/2009: read the first line
             line = datasetFile.readline()
diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
index 6bc0ef77..f74e655d 100755
--- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
+++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
@@ -43,7 +43,6 @@ from pprint import pformat as pf
 from htmlgen import HTMLgen2 as HT
 import reaper
 
-from base import webqtlConfig
 from utility.THCell import THCell
 from utility.TDCell import TDCell
 from base.trait import GeneralTrait
diff --git a/wqflask/wqflask/ctl/__init__.py b/wqflask/wqflask/ctl/__init__.py
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/wqflask/ctl/__init__.py
diff --git a/wqflask/wqflask/ctl/ctl_analysis.py b/wqflask/wqflask/ctl/ctl_analysis.py
new file mode 100644
index 00000000..7a42b2f8
--- /dev/null
+++ b/wqflask/wqflask/ctl/ctl_analysis.py
@@ -0,0 +1,194 @@
+# CTL analysis for GN2
+# Author / Maintainer: Danny Arends <Danny.Arends@gmail.com>
+import sys
+from numpy import *
+import scipy as sp                            # SciPy
+import rpy2.robjects as ro                    # R Objects
+import rpy2.rinterface as ri
+
+from base.webqtlConfig import GENERATED_IMAGE_DIR
+from utility import webqtlUtil                # Random number for the image
+from utility import genofile_parser           # genofile_parser
+
+import base64
+import array
+import csv
+import itertools
+
+from base import data_set
+from base import trait as TRAIT
+
+from utility import helper_functions
+from utility.tools import locate
+
+from rpy2.robjects.packages import importr
+utils = importr("utils")
+
+## Get pointers to some common R functions
+r_library       = ro.r["library"]             # Map the library function
+r_options       = ro.r["options"]             # Map the options function
+r_read_csv      = ro.r["read.csv"]            # Map the read.csv function
+r_dim           = ro.r["dim"]                 # Map the dim function
+r_c             = ro.r["c"]                   # Map the c function
+r_t             = ro.r["t"]                   # Map the t function
+r_cat           = ro.r["cat"]                 # Map the cat function
+r_paste         = ro.r["paste"]               # Map the paste function
+r_unlist        = ro.r["unlist"]              # Map the unlist function
+r_head          = ro.r["head"]                # Map the unlist function
+r_unique        = ro.r["unique"]              # Map the unique function
+r_length        = ro.r["length"]              # Map the length function
+r_unlist        = ro.r["unlist"]              # Map the unlist function
+r_list          = ro.r.list                   # Map the list function
+r_matrix        = ro.r.matrix                 # Map the matrix function
+r_seq           = ro.r["seq"]                 # Map the seq function
+r_table         = ro.r["table"]               # Map the table function
+r_names         = ro.r["names"]               # Map the names function
+r_sink          = ro.r["sink"]                # Map the sink function
+r_is_NA         = ro.r["is.na"]               # Map the is.na function
+r_file          = ro.r["file"]                # Map the file function
+r_png           = ro.r["png"]                 # Map the png function for plotting
+r_dev_off       = ro.r["dev.off"]             # Map the dev.off function
+r_save_image    = ro.r["save.image"]          # Map the save.image function
+r_class         = ro.r["class"]               # Map the class function
+r_save          = ro.r["save"]                # Map the save function
+r_write_table   = ro.r["write.table"]         # Map the write.table function
+r_read_table   = ro.r["read.table"]         # Map the read.table function
+r_as_data_frame = ro.r["as.data.frame"]         # Map the write.table function
+r_data_frame    = ro.r["data.frame"]         # Map the write.table function
+r_as_numeric    = ro.r["as.numeric"]         # Map the write.table function
+
+class CTL(object):
+    def __init__(self):
+        print("Initialization of CTL")
+        #log = r_file("/tmp/genenetwork_ctl.log", open = "wt")
+        #r_sink(log)                                  # Uncomment the r_sink() commands to log output from stdout/stderr to a file
+        #r_sink(log, type = "message")
+        r_library("ctl")                                                  # Load CTL - Should only be done once, since it is quite expensive
+        r_options(stringsAsFactors = False)
+        print("Initialization of CTL done, package loaded in R session")
+        self.r_CTLscan            = ro.r["CTLscan"]                        # Map the CTLscan function
+        self.r_CTLsignificant     = ro.r["CTLsignificant"]                 # Map the CTLsignificant function
+        self.r_lineplot           = ro.r["ctl.lineplot"]                   # Map the ctl.lineplot function
+        self.r_CTLsignificant     = ro.r["CTLsignificant"]                 # Map the CTLsignificant function
+        self.r_CTLnetwork         = ro.r["CTLnetwork"]                     # Map the CTLnetwork function
+        self.r_CTLprofiles        = ro.r["CTLprofiles"]                    # Map the CTLprofiles function
+        self.r_plotCTLobject      = ro.r["plot.CTLobject"]                 # Map the CTLsignificant function
+        print("Obtained pointers to CTL functions")
+
+    def run_analysis(self, requestform):
+        print("Starting CTL analysis on dataset")
+        self.trait_db_list = [trait.strip() for trait in requestform['trait_list'].split(',')]
+        self.trait_db_list = [x for x in self.trait_db_list if x]
+
+        print("strategy:", requestform.get("strategy"))
+        strategy = requestform.get("strategy")
+
+        print("nperm:", requestform.get("nperm"))
+        nperm = int(requestform.get("nperm"))
+
+        print("parametric:", requestform.get("parametric"))
+        parametric = bool(requestform.get("parametric"))
+
+        print("significance:", requestform.get("significance"))
+        significance = float(requestform.get("significance"))
+
+        # Get the name of the .geno file belonging to the first phenotype
+        datasetname = self.trait_db_list[0].split(":")[1]
+        dataset = data_set.create_dataset(datasetname)
+
+        genofilelocation = locate(dataset.group.name + ".geno", "genotype")
+        parser = genofile_parser.ConvertGenoFile(genofilelocation)
+        parser.process_csv()
+
+        # Create a genotype matrix
+        individuals = parser.individuals
+        markers = []
+        markernames = []
+        for marker in parser.markers:
+          markernames.append(marker["name"])
+          markers.append(marker["genotypes"])
+
+        genotypes = list(itertools.chain(*markers))
+        print(len(genotypes) / len(individuals), "==", len(parser.markers))
+
+        rGeno = r_t(ro.r.matrix(r_unlist(genotypes), nrow=len(markernames), ncol=len(individuals), dimnames = r_list(markernames, individuals), byrow=True))
+
+        # Create a phenotype matrix
+        traits = []
+        for trait in self.trait_db_list:
+          print("retrieving data for", trait)
+          if trait != "":
+            ts = trait.split(':')
+            gt = TRAIT.GeneralTrait(name = ts[0], dataset_name = ts[1])
+            gt.retrieve_sample_data(individuals)
+            for ind in individuals:
+              if ind in gt.data.keys():
+                traits.append(gt.data[ind].value)
+              else:
+                traits.append("-999")
+
+        rPheno = r_t(ro.r.matrix(r_as_numeric(r_unlist(traits)), nrow=len(self.trait_db_list), ncol=len(individuals), dimnames = r_list(self.trait_db_list, individuals), byrow=True))
+
+        # Use a data frame to store the objects
+        rPheno = r_data_frame(rPheno)
+        rGeno = r_data_frame(rGeno)
+
+        # Debug: Print the genotype and phenotype files to disk
+        #r_write_table(rGeno, "~/outputGN/geno.csv")
+        #r_write_table(rPheno, "~/outputGN/pheno.csv")
+
+        # Perform the CTL scan
+        res = self.r_CTLscan(rGeno, rPheno, strategy = strategy, nperm = nperm, parametric = parametric, ncores = 6)
+
+        # Get significant interactions
+        significant = self.r_CTLsignificant(res, significance = significance)
+
+        # Create an image for output
+        self.results = {}
+        self.results['imgurl1'] = webqtlUtil.genRandStr("CTLline_") + ".png"
+        self.results['imgloc1'] = GENERATED_IMAGE_DIR + self.results['imgurl1']
+
+        self.results['ctlresult'] = significant
+        self.results['requestform'] = requestform             # Store the user specified parameters for the output page
+
+        # Create the lineplot
+        r_png(self.results['imgloc1'], width=1000, height=600, type='cairo-png')
+        self.r_lineplot(res, significance = significance)
+        r_dev_off()
+
+        n = 2
+        for trait in self.trait_db_list:
+          # Create the QTL like CTL plots
+          self.results['imgurl' + str(n)] = webqtlUtil.genRandStr("CTL_") + ".png"
+          self.results['imgloc' + str(n)] = GENERATED_IMAGE_DIR + self.results['imgurl' + str(n)]
+          r_png(self.results['imgloc' + str(n)], width=1000, height=600, type='cairo-png')
+          self.r_plotCTLobject(res, (n-1), significance = significance, main='Phenotype ' + trait)
+          r_dev_off()
+          n = n + 1
+
+        # Flush any output from R
+        sys.stdout.flush()
+
+    def loadImage(self, path, name):
+        print("pre-loading imgage results:", self.results[path])
+        imgfile = open(self.results[path], 'rb')
+        imgdata = imgfile.read()
+        imgB64 = imgdata.encode("base64")
+        bytesarray = array.array('B', imgB64)
+        self.results[name] = bytesarray
+
+    def render_image(self, results):
+        self.loadImage("imgloc1", "imgdata1")
+        n = 2
+        for trait in self.trait_db_list:
+          self.loadImage("imgloc" + str(n), "imgdata" + str(n))
+          n = n + 1
+
+    def process_results(self, results):
+        print("Processing CTL output")
+        template_vars = {}
+        template_vars["results"] = self.results
+        self.render_image(self.results)
+        sys.stdout.flush()
+        return(dict(template_vars))
+
diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py
index 159c5d6c..2f544d44 100755
--- a/wqflask/wqflask/database.py
+++ b/wqflask/wqflask/database.py
@@ -24,8 +24,9 @@ def init_db():
     # you will have to import them first before calling init_db()
     #import yourapplication.models
     import wqflask.model
-    print("Creating all..")
+    print("database.py: Creating all model metadata..")
     Base.metadata.create_all(bind=engine)
-    print("Done creating all...")
+    print("database.py: Done creating all model metadata...")
+    print("Point your browser at http://localhost:5003/")
     
 init_db()
diff --git a/wqflask/wqflask/heatmap/heatmap.py b/wqflask/wqflask/heatmap/heatmap.py
index 40f518f0..2445b37f 100644
--- a/wqflask/wqflask/heatmap/heatmap.py
+++ b/wqflask/wqflask/heatmap/heatmap.py
@@ -26,13 +26,12 @@ import reaper
 from base.trait import GeneralTrait
 from base import data_set
 from base import species
-from base import webqtlConfig
-from utility import webqtlUtil
 # from wqflask.my_pylmm.pyLMM import lmm
 # from wqflask.my_pylmm.pyLMM import input
 from utility import helper_functions
 from utility import Plot, Bunch
 from utility import temp_data
+from utility.tools import PYLMM_COMMAND
 
 from MySQLdb import escape_string as escape
 
@@ -214,7 +213,7 @@ class Heatmap(object):
             #Redis.expire(key, 60*60)
             #print("before printing command")
             #
-            #command = 'python /home/zas1024/gene/wqflask/wqflask/my_pylmm/pyLMM/lmm.py --key {} --species {}'.format(key,
+            #command = 'python lmm.py --key {} --species {}'.format(key,
             #                                                                                                        "other")
             #print("command is:", command)
             #print("after printing command")
@@ -273,7 +272,7 @@ class Heatmap(object):
             Redis.expire(key, 60*60)
             print("before printing command")
             
-            command = 'python /home/zas1024/gene/wqflask/wqflask/my_pylmm/pyLMM/lmm.py --key {} --species {}'.format(key,
+            command = PYLMM_COMMAND+' --key {} --species {}'.format(key,
                                                                                                                     "other")
             print("command is:", command)
             print("after printing command")
diff --git a/wqflask/wqflask/interval_analyst/IntervalAnalystPage.py b/wqflask/wqflask/interval_analyst/IntervalAnalystPage.py
index ec9aa29c..f45ec0c4 100755
--- a/wqflask/wqflask/interval_analyst/IntervalAnalystPage.py
+++ b/wqflask/wqflask/interval_analyst/IntervalAnalystPage.py
@@ -45,40 +45,40 @@ class IntervalAnalystPage(templatePage):
 	#A dictionary that lets us map the html form names "txStart_mm6" -> "Mb Start (mm8)"
 	#the first item is the short name (column headers) and the second item is the long name (dropdown list)
 	#   [short name, long name, category]
-	columnNames = {"GeneSymbol" : ["Gene", "Gene Name", 'gene'], 
+	columnNames = {"GeneSymbol" : ["Gene", "Gene Name", 'gene'],
 			"GeneDescription" : ["Description", "Gene Description", 'species'],
-			'GeneNeighborsCount' : ["Neighbors", "Gene Neighbors", 'gene'], 
-			'GeneNeighborsRange' : ["Neighborhood", "Gene Neighborhood (Mb)", 'gene'], 
-			'GeneNeighborsDensity' : ["Gene Density", "Gene Density (Neighbors/Mb)", 'gene'],  
+			'GeneNeighborsCount' : ["Neighbors", "Gene Neighbors", 'gene'],
+			'GeneNeighborsRange' : ["Neighborhood", "Gene Neighborhood (Mb)", 'gene'],
+			'GeneNeighborsDensity' : ["Gene Density", "Gene Density (Neighbors/Mb)", 'gene'],
 			"ProteinID" : ["Prot ID", "Protein ID", 'protein'],
-			"Chromosome" : ["Chr", "Chromosome", 'species'], 
-			"TxStart" : ["Start", "Mb Start", 'species'], 
-			"TxEnd" : ["End", "Mb End", 'species'], 
-			"GeneLength" : ["Length", "Kb Length", 'species'], 
-			"cdsStart" : ["CDS Start", "Mb CDS Start", 'species'], 
+			"Chromosome" : ["Chr", "Chromosome", 'species'],
+			"TxStart" : ["Start", "Mb Start", 'species'],
+			"TxEnd" : ["End", "Mb End", 'species'],
+			"GeneLength" : ["Length", "Kb Length", 'species'],
+			"cdsStart" : ["CDS Start", "Mb CDS Start", 'species'],
 			"cdsEnd" : ["CDS End", "Mb CDS End", 'species'],
-			"exonCount" : ["Num Exons", "Exon Count", 'species'], 
-			"exonStarts" : ["Exon Starts", "Exon Starts", 'species'], 
-			"exonEnds" : ["Exon Ends", "Exon Ends", 'species'], 
-			"Strand" : ["Strand", "Strand", 'species'], 
+			"exonCount" : ["Num Exons", "Exon Count", 'species'],
+			"exonStarts" : ["Exon Starts", "Exon Starts", 'species'],
+			"exonEnds" : ["Exon Ends", "Exon Ends", 'species'],
+			"Strand" : ["Strand", "Strand", 'species'],
 			"GeneID" : ["Gene ID", "Gene ID", 'species'],
-			"GenBankID" : ["GenBank", "GenBank ID", 'species'], 
+			"GenBankID" : ["GenBank", "GenBank ID", 'species'],
 			"UnigenID" : ["Unigen", "Unigen ID", 'species'],
-			"NM_ID" : ["NM ID", "NM ID", 'species'], 
+			"NM_ID" : ["NM ID", "NM ID", 'species'],
 			"kgID" : ["kg ID", "kg ID", 'species'],
-			"snpCount" : ["SNPs", "SNP Count", 'species'], 
-			"snpDensity" : ["SNP Density", "SNP Density", 'species'], 
-			"lrs" : ["LRS", "Likelihood Ratio Statistic", 'misc'], 
-			"lod" : ["LOD", "Likelihood Odds Ratio", 'misc'], 
-			"pearson" : ["Pearson", "Pearson Product Moment", 'misc'], 
-			"literature" : ["Lit Corr", "Literature Correlation", 'misc'], 
+			"snpCount" : ["SNPs", "SNP Count", 'species'],
+			"snpDensity" : ["SNP Density", "SNP Density", 'species'],
+			"lrs" : ["LRS", "Likelihood Ratio Statistic", 'misc'],
+			"lod" : ["LOD", "Likelihood Odds Ratio", 'misc'],
+			"pearson" : ["Pearson", "Pearson Product Moment", 'misc'],
+			"literature" : ["Lit Corr", "Literature Correlation", 'misc'],
 			}
 
 	###Species Freeze
 	speciesFreeze = {'mouse':'mm9', 'rat':'rn3', 'human':'hg19'}
 	for key in speciesFreeze.keys():
 		speciesFreeze[speciesFreeze[key]] = key
-	
+
 	def __init__(self, fd):
 
 		templatePage.__init__(self, fd)
@@ -86,7 +86,7 @@ class IntervalAnalystPage(templatePage):
 		fd.formdata['remote_ip'] = fd.remote_ip
 		if not self.openMysql():
 			return
-		
+
 		self.species = fd.formdata.getvalue("species", "mouse")
 		try:
 			self.startMb = float(fd.formdata.getvalue("startMb"))
@@ -96,7 +96,7 @@ class IntervalAnalystPage(templatePage):
 			self.endMb = float(fd.formdata.getvalue("endMb"))
 		except:
 			self.endMb = self.startMb + 10
-			
+
 		self.Chr = fd.formdata.getvalue("chromosome", "1")
 		self.xls = fd.formdata.getvalue("xls", "1")
 		try:
@@ -107,38 +107,38 @@ class IntervalAnalystPage(templatePage):
 			self.diffColDefault = self.diffCol = []
 			if self.species !=  'mouse':
 				self.diffColDefault = [2, 3]#default is B6 and D2 for other species
-			
+
 		controlFrm, dispFields = self.genControlForm(fd)
 		geneTable, filename = self.genGeneTable(fd, dispFields)
-		
+
 		infoTD = HT.TD(width=400, valign= "top")
-		infoTD.append(HT.Paragraph("Interval Analyst : Chr %s" % self.Chr, Class="title"), 
-			HT.Strong("Species : "), self.species.title(), HT.BR(),  
-			HT.Strong("Database : "), "UCSC %s" % self.speciesFreeze[self.species], HT.BR(),  
-			HT.Strong("Range : "), "%2.6f Mb - %2.6f Mb" % (self.startMb, self.endMb), HT.BR(),  
+		infoTD.append(HT.Paragraph("Interval Analyst : Chr %s" % self.Chr, Class="title"),
+			HT.Strong("Species : "), self.species.title(), HT.BR(),
+			HT.Strong("Database : "), "UCSC %s" % self.speciesFreeze[self.species], HT.BR(),
+			HT.Strong("Range : "), "%2.6f Mb - %2.6f Mb" % (self.startMb, self.endMb), HT.BR(),
 			)
 		if filename:
 			infoTD.append(HT.BR(), HT.BR(), HT.Href(text="Download", url = "/tmp/" + filename, Class="normalsize")
 					, " output in MS excel format.")
-		
+
 		mainTable = HT.TableLite(HT.TR(infoTD, HT.TD(controlFrm, Class="doubleBorder", width=400), HT.TD("&nbsp;", width="")), cellpadding=10)
 		mainTable.append(HT.TR(HT.TD(geneTable, colspan=3)))
 		self.dict['body'] = HT.TD(mainTable)
 		self.dict['title'] = "Interval Analyst"
-		
+
 	def genGeneTable(self, fd, dispFields):
 		filename = ""
 		if self.xls:
 			#import pyXLWriter as xl
 			filename = "IntAn_Chr%s_%2.6f-%2.6f" % (self.Chr, self.startMb, self.endMb)
 			filename += ".xls"
-			
+
 			# Create a new Excel workbook
 			workbook = xl.Writer(os.path.join(webqtlConfig.TMPDIR, filename))
 			worksheet = workbook.add_worksheet()
 			titleStyle = workbook.add_format(align = 'left', bold = 0, size=18, border = 1, border_color="gray")
 			headingStyle = workbook.add_format(align = 'center', bold = 1, size=13, fg_color = 0x1E, color="white", border = 1, border_color="gray")
-			
+
 			##Write title Info
 			worksheet.write([0, 0], "GeneNetwork Interval Analyst Table", titleStyle)
 			worksheet.write([1, 0], "%s%s" % (webqtlConfig.PORTADDR, os.path.join(webqtlConfig.CGIDIR, self._scriptfile)))
@@ -148,12 +148,12 @@ class IntervalAnalystPage(templatePage):
 			worksheet.write([4, 0], "Search by : %s" % fd.formdata['remote_ip'])
 			worksheet.write([5, 0], "view region : Chr %s %2.6f - %2.6f Mb" % (self.Chr, self.startMb, self.endMb))
 			nTitleRow = 7
-			
+
 		geneTable = HT.TableLite(Class="collap", cellpadding=5)
 		headerRow = HT.TR(HT.TD(" ", Class="fs13 fwb ffl b1 cw cbrb", width="1"))
 		if self.xls:
 			worksheet.write([nTitleRow, 0], "Index", headingStyle)
-			
+
 		for ncol, column in enumerate(dispFields):
 			if len(column) == 1:
 				headerRow.append(HT.TD(self.columnNames[column[0]][0], Class="fs13 fwb ffl b1 cw cbrb", NOWRAP=1,align="Center"))
@@ -162,24 +162,24 @@ class IntervalAnalystPage(templatePage):
 					worksheet.write([nTitleRow, ncol+1], colTitle, headingStyle)
 					worksheet.set_column([ncol+1, ncol+1], 2*len(colTitle))
 			else:
-				headerRow.append(HT.TD(self.columnNames[column[0]][0], HT.BR(), " (%s)" % self.speciesFreeze[column[1]], 
+				headerRow.append(HT.TD(self.columnNames[column[0]][0], HT.BR(), " (%s)" % self.speciesFreeze[column[1]],
 					Class="fs13 fwb ffl b1 cw cbrb", NOWRAP=1, align="Center"))
 				if self.xls:
 					colTitle = self.columnNames[column[0]][0] + " (%s)" % self.speciesFreeze[column[1]]
 					worksheet.write([nTitleRow, ncol+1], colTitle, headingStyle)
 					worksheet.set_column([ncol+1, ncol+1], 2*len(colTitle))
-				#headerRow.append(HT.TD(self.columnNames[column[0]][0], HT.BR(), 
-				#	"(%s %s)" % (column[1].title(), self.speciesFreeze[column[1]]), 
+				#headerRow.append(HT.TD(self.columnNames[column[0]][0], HT.BR(),
+				#	"(%s %s)" % (column[1].title(), self.speciesFreeze[column[1]]),
 				#	Class="colorBlue", NOWRAP=1, align="Center"))
 		geneTable.append(headerRow)
-		
+
 		geneCol = GeneUtil.loadGenes(self.cursor, self.Chr, self.diffColDefault, self.startMb, self.endMb, species=self.species)
 		for gIndex, theGO in enumerate(geneCol):
 			geneRow = HT.TR(HT.TD(gIndex+1, Class="fs12 fwn b1", align="right"))
 			if self.xls:
 				nTitleRow += 1
 				worksheet.write([nTitleRow, 0], gIndex + 1)
-				
+
 			for ncol, column in enumerate(dispFields):
 				if len(column) == 1 or column[1]== self.species:
 					keyValue = ""
@@ -196,17 +196,17 @@ class IntervalAnalystPage(templatePage):
 					curGO = theGO[subGO]
 					if theGO[subGO].has_key(fieldName):
 						keyValue = theGO[subGO][fieldName]
-				
+
 				if self.xls:
 					worksheet.write([nTitleRow, ncol+1], keyValue)
 				geneRow.append(self.formatTD(keyValue, fieldName, curSpecies, curGO))
-					
+
 			geneTable.append(geneRow)
-			
+
 		if self.xls:
 			workbook.close()
 		return geneTable, filename
-	
+
 	def formatTD(self, keyValue, fieldName, Species, theGO):
 		if keyValue is None:
 			keyValue = ""
@@ -219,7 +219,7 @@ class IntervalAnalystPage(templatePage):
 					keyValue = ""
 				return HT.TD(keyValue, Class="fs12 fwn b1", width=300)
 			elif fieldName in ("GeneSymbol"):
-				webqtlLink = HT.Href("./%s?cmd=sch&gene=%s&alias=1&species=%s" % (webqtlConfig.SCRIPTFILE, keyValue, Species), 		
+				webqtlLink = HT.Href("./%s?cmd=sch&gene=%s&alias=1&species=%s" % (webqtlConfig.SCRIPTFILE, keyValue, Species), 
 					HT.Image("/images/webqtl_search.gif", border=0, valign="top"), target="_blank")
 				if theGO['GeneID']:
 					geneSymbolLink = HT.Href(webqtlConfig.NCBI_LOCUSID % theGO['GeneID'], keyValue, Class="normalsize", target="_blank")
@@ -236,8 +236,8 @@ class IntervalAnalystPage(templatePage):
 				return HT.TD(keyValue, Class="fs12 fwn b1",align="right")
 			elif fieldName in ("snpCount"):
 				if keyValue:
-					snpString = HT.Href(url="%s&chr=%s&start=%s&end=%s&geneName=%s&s1=%d&s2=%d" % (os.path.join(webqtlConfig.CGIDIR, 'main.py?FormID=snpBrowser'), 
-							theGO["Chromosome"], theGO["TxStart"], theGO["TxEnd"], theGO["GeneSymbol"], self.diffColDefault[0], self.diffColDefault[1]), 
+					snpString = HT.Href(url="%s&chr=%s&start=%s&end=%s&geneName=%s&s1=%d&s2=%d" % (os.path.join(webqtlConfig.CGIDIR, 'main.py?FormID=snpBrowser'),
+							theGO["Chromosome"], theGO["TxStart"], theGO["TxEnd"], theGO["GeneSymbol"], self.diffColDefault[0], self.diffColDefault[1]),
 							text=theGO["snpCount"], target="_blank", Class="normalsize")
 				else:
 					snpString = keyValue
@@ -252,13 +252,13 @@ class IntervalAnalystPage(templatePage):
 				return HT.TD(keyValue, Class="fs12 fwn b1",NOWRAP=1)
 		else:
 			return HT.TD(keyValue, Class="fs12 fwn b1",NOWRAP=1,align="right")
-				
+
 	def genControlForm(self, fd):
 		##desc GeneList
 		self.cursor.execute("Desc GeneList")
 		GeneListFields = self.cursor.fetchall()
 		GeneListFields = map(lambda X: X[0], GeneListFields)
-		
+
 		#group columns by category--used for creating the dropdown list of possible columns
 		categories = {}
 		for item in self.columnNames.keys():
@@ -267,7 +267,7 @@ class IntervalAnalystPage(templatePage):
 				categories[category[-1]] = [item ]
 			else:
 				categories[category[-1]] = categories[category[-1]]+[item]
-	
+
 		##List All Species in the Gene Table
 		speciesDict = {}
 		self.cursor.execute("select Species.Name, GeneList.SpeciesId from Species, GeneList where \
@@ -292,34 +292,34 @@ class IntervalAnalystPage(templatePage):
 					pass
 				AppliedField.append(item2)
 			categories[specName] = AppliedField
-			
+
 		categoriesOrder += ['misc']
-		
+
 		############################################################
 		## Create the list of possible columns for the dropdown list
 		############################################################
 		allColumnsList = HT.Select(name="allColumns", Class="snpBrowserDropBox")
-		
+
 		for category in categoriesOrder:
 			allFields = categories[category]
 			if allFields:
 				geneOpt = HT.Optgroup(label=category.title())
 				for item in allFields:
 					if category in self.speciesFreeze.keys():
-						geneOpt.append(("%s (%s %s)" % (self.columnNames[item][1], category.title(), self.speciesFreeze[category]), 
+						geneOpt.append(("%s (%s %s)" % (self.columnNames[item][1], category.title(), self.speciesFreeze[category]),
 							"%s__%s" % (item, self.speciesFreeze[category])))
 					else:
 						geneOpt.append((self.columnNames[item][1], item))
 				geneOpt.sort()
 				allColumnsList.append(geneOpt)
-		
+
 		######################################
 		## Create the list of selected columns
 		######################################
-		
+
 		#cols contains the value of all the selected columns
 		submitCols = cols = fd.formdata.getvalue("columns", "default")
-		
+
 		if cols == "default":
 			if self.species=="mouse":  #these are the same columns that are shown on intervalPage.py
 				cols = ['GeneSymbol', 'GeneDescription', 'Chromosome', 'TxStart', 'Strand', 'GeneLength', 'GeneID', 'NM_ID', 'snpCount', 'snpDensity']
@@ -331,12 +331,12 @@ class IntervalAnalystPage(templatePage):
 		else:
 			if type(cols)==type(""):
 				cols = [cols]
-			
+
 		colsLst = []
 		dispFields = []
 		for column in cols:
 			if submitCols == "default" and column not in ('GeneSymbol') and (column in GeneListFields or column in speciesField):
-				colsLst.append(("%s (%s %s)" % (self.columnNames[column][1], self.species.title(), self.speciesFreeze[self.species]), 
+				colsLst.append(("%s (%s %s)" % (self.columnNames[column][1], self.species.title(), self.speciesFreeze[self.species]),
 							"%s__%s" % (column, self.speciesFreeze[self.species])))
 				dispFields.append([column, self.species])
 			else:
@@ -346,17 +346,17 @@ class IntervalAnalystPage(templatePage):
 					dispFields.append([column])
 				else:
 					thisSpecies = self.speciesFreeze[column2[1]]
-					colsLst.append(("%s (%s %s)" % (self.columnNames[column2[0]][1], thisSpecies.title(), column2[1]), 
+					colsLst.append(("%s (%s %s)" % (self.columnNames[column2[0]][1], thisSpecies.title(), column2[1]),
 							column))
 					dispFields.append((column2[0], thisSpecies))
 		selectedColumnsList = HT.Select(name="columns", Class="snpBrowserSelectBox", multiple="true", data=colsLst, size=6)
-		
+
 		##########################
         ## Create the columns form
-		##########################		
+		##########################
 		columnsForm = HT.Form(name="columnsForm", submit=HT.Input(type='hidden'), cgi=os.path.join(webqtlConfig.CGIDIR, self._scriptfile), enctype="multipart/form-data")
 		columnsForm.append(HT.Input(type="hidden", name="fromdatabase", value= fd.formdata.getvalue("fromdatabase", "unknown")))
-		columnsForm.append(HT.Input(type="hidden", name="species", value=self.species))	
+		columnsForm.append(HT.Input(type="hidden", name="species", value=self.species))
 		if self.diffCol:
 			columnsForm.append(HT.Input(type="hidden", name="s1", value=self.diffCol[0]))
 			columnsForm.append(HT.Input(type="hidden", name="s2", value=self.diffCol[1]))
@@ -366,8 +366,8 @@ class IntervalAnalystPage(templatePage):
 		removeButton = HT.Input(type="button", name="remove", value="Remove", Class="button", onClick="removeFromList(this.form.columns.selectedIndex, this.form.columns)")
 		upButton = HT.Input(type="button", name="up", value="Up", Class="button", onClick="swapOptions(this.form.columns.selectedIndex, this.form.columns.selectedIndex-1, this.form.columns)")
 		downButton = HT.Input(type="button", name="down", value="Down", Class="button", onClick="swapOptions(this.form.columns.selectedIndex, this.form.columns.selectedIndex+1, this.form.columns)")
-		clearButton = HT.Input(type="button", name="clear", value="Clear", Class="button", onClick="deleteAllElements(this.form.columns)")		
-		submitButton = HT.Input(type="submit", value="Refresh", Class="button", onClick="selectAllElements(this.form.columns)")		
+		clearButton = HT.Input(type="button", name="clear", value="Clear", Class="button", onClick="deleteAllElements(this.form.columns)")
+		submitButton = HT.Input(type="submit", value="Refresh", Class="button", onClick="selectAllElements(this.form.columns)")
 
 		selectChrBox = HT.Select(name="chromosome")
 		self.cursor.execute("""
@@ -375,11 +375,11 @@ class IntervalAnalystPage(templatePage):
 				Chr_Length.Name, Length from Chr_Length, Species
 			where
 				Chr_Length.SpeciesId = Species.Id AND
-				Species.Name = '%s' 
+				Species.Name = '%s'
 			Order by
 				Chr_Length.OrderId
 			""" % self.species)
-		
+
 		results = self.cursor.fetchall()
 		for chrInfo in results:
 			selectChrBox.append((chrInfo[0], chrInfo[0]))
@@ -401,5 +401,5 @@ class IntervalAnalystPage(templatePage):
 		#columnsForm.append(HT.Input(type="hidden", name="sort", value=diffCol),
 		#		   HT.Input(type="hidden", name="identification", value=identification),
 		#		   HT.Input(type="hidden", name="traitInfo", value=traitInfo))
-		
+
 		return columnsForm, dispFields
diff --git a/wqflask/wqflask/marker_regression/MarkerRegressionPage.py b/wqflask/wqflask/marker_regression/MarkerRegressionPage.py
index d02d80b3..4c3391e5 100755
--- a/wqflask/wqflask/marker_regression/MarkerRegressionPage.py
+++ b/wqflask/wqflask/marker_regression/MarkerRegressionPage.py
@@ -72,7 +72,7 @@ class MarkerRegressionPage(templatePage):
             #automatically generate pheno txt file for PLINK
             self.genPhenoTxtFileForPlink(phenoFileName=plinkOutputFileName,RISetName=fd.RISet,probesetName=probesetName, valueDict=allTraitValueDict)
             # os.system full path is required for input and output files; specify missing value is -9999
-            plink_command = '%splink/plink --noweb --ped %splink/%s.ped --no-fid --no-parents --no-sex --no-pheno --map %splink/%s.map --pheno %s/%s.txt --pheno-name %s --missing-phenotype -9999 --out %s%s --assoc ' % (webqtlConfig.HTMLPATH, webqtlConfig.HTMLPATH,  fd.RISet, webqtlConfig.HTMLPATH, fd.RISet, webqtlConfig.TMPDIR, plinkOutputFileName, probesetName, webqtlConfig.TMPDIR, plinkOutputFileName)
+            plink_command = '%splink/plink --noweb --ped %splink/%s.ped --no-fid --no-parents --no-sex --no-pheno --map %splink/%s.map --pheno %s/%s.txt --pheno-name %s --missing-phenotype -9999 --out %s%s --assoc ' % (webqtlConfig.GENODIR, webqtlConfig.GENODIR,  fd.RISet, webqtlConfig.GENODIR, fd.RISet, webqtlConfig.TMPDIR, plinkOutputFileName, probesetName, webqtlConfig.TMPDIR, plinkOutputFileName)
 
             os.system(plink_command)
 
@@ -140,7 +140,7 @@ class MarkerRegressionPage(templatePage):
                 intCanvas = pid.PILCanvas(size=(self.graphWidth,self.graphHeight))
                 gifmap = self.plotIntMappingForPLINK(fd, intCanvas, startMb = self.startMb, endMb = self.endMb, plinkResultDict=plinkResultDict)
 
-                intCanvas.save(os.path.join(webqtlConfig.IMGDIR, filename), format='png')
+                intCanvas.save(os.path.join(webqtlConfig.GENERATED_IMAGE_DIR, filename), format='png')
                 intImg=HT.Image('/image/'+filename+'.png', border=0, usemap='#WebQTLImageMap')
 
                 TD_LR = HT.TR(HT.TD(HT.Blockquote(gifmap,intImg, HT.P()), bgColor='#eeeeee', height = 200))
@@ -249,7 +249,7 @@ class MarkerRegressionPage(templatePage):
                 intCanvas = pid.PILCanvas(size=(self.graphWidth,self.graphHeight))
                 gifmap = self.plotIntMapping(fd, intCanvas, startMb = self.startMb, endMb = self.endMb, showLocusForm= "")
                 filename= webqtlUtil.genRandStr("Itvl_")
-                intCanvas.save(os.path.join(webqtlConfig.IMGDIR, filename), format='png')
+                intCanvas.save(os.path.join(webqtlConfig.GENERATED_IMAGE_DIR, filename), format='png')
                 intImg=HT.Image('/image/'+filename+'.png', border=0, usemap='#WebQTLImageMap')
 
                 ################################################################
@@ -458,7 +458,7 @@ class MarkerRegressionPage(templatePage):
         #plotBar(myCanvas,10,10,390,290,LRSArray,XLabel='LRS',YLabel='Frequency',title=' Histogram of Permutation Test',identification=fd.identification)
         Plot.plotBar(myCanvas, LRSArray,XLabel='LRS',YLabel='Frequency',title=' Histogram of Permutation Test')
         filename= webqtlUtil.genRandStr("Reg_")
-        myCanvas.save(webqtlConfig.IMGDIR+filename, format='gif')
+        myCanvas.save(webqtlConfig.GENERATED_IMAGE_DIR+filename, format='gif')
         img=HT.Image('/image/'+filename+'.gif',border=0,alt='Histogram of Permutation Test')
             
         if fd.suggestive == None:
@@ -1597,7 +1597,7 @@ class MarkerRegressionPage(templatePage):
 
     # get strain name from ped file in order
     def getStrainNameFromPedFile(self, RISetName=''):
-        pedFileopen= open("%splink/%s.ped"%(webqtlConfig.HTMLPATH, RISetName),"r")
+        pedFileopen= open("%splink/%s.ped"%(webqtlConfig.GENODIR, RISetName),"r")
         line =pedFileopen.readline()
         strainNameList=[]
 
diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py
index cfcd4783..caea5802 100644
--- a/wqflask/wqflask/marker_regression/gemma_mapping.py
+++ b/wqflask/wqflask/marker_regression/gemma_mapping.py
@@ -1,9 +1,7 @@
 import os
 
 from base import webqtlConfig
-from utility.tools import gemma_command
-
-GEMMA_PATH,GEMMA_COMMAND = gemma_command()
+from utility.tools import GEMMA_COMMAND
 
 def run_gemma(this_dataset, samples, vals): 
     """Generates p-values for each marker using GEMMA"""
@@ -12,8 +10,11 @@ def run_gemma(this_dataset, samples, vals):
 
     gen_pheno_txt_file(this_dataset, samples, vals)
 
-    os.chdir(GEMMA_PATH)
+    # Don't do this!
+    # os.chdir("{}gemma".format(webqtlConfig.GENODIR))
 
+    # use GEMMA_RUN in the next one, create a unique temp file
+    
     gemma_command = GEMMA_COMMAND + ' -bfile %s/%s -k %s/output/%s.cXX.txt -lmm 1 -o %s_output' % (GEMMA_PATH,
                                                                                     this_dataset.group.name,
                                                                                     GEMMA_PATH,
@@ -46,4 +47,4 @@ def parse_gemma_output(this_dataset):
                 p_values.append(float(line.split("\t")[10]))
 
     #print("p_values: ", p_values)
-    return included_markers, p_values
\ No newline at end of file
+    return included_markers, p_values
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index c0bfd70b..08f422f0 100644
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -30,21 +30,16 @@ from flask import Flask, g
 from base.trait import GeneralTrait
 from base import data_set
 from base import species
-from base import webqtlConfig
 from utility import webqtlUtil
 from utility import helper_functions
 from utility import Plot, Bunch
 from utility import temp_data
 from utility.benchmark import Bench
-from utility.tools import pylmm_command, plink_command, gemma_command
 from wqflask.marker_regression import gemma_mapping
-#from wqflask.marker_regression import qtl_reaper_mapping
-#from wqflask.marker_regression import plink_mapping
-#from wqflask.marker_regression import rqtl_mapping
 
-PYLMM_PATH,PYLMM_COMMAND = pylmm_command()
-PLINK_PATH,PLINK_COMMAND = plink_command()
-GEMMA_PATH,GEMMA_COMMAND = gemma_command()
+from utility.tools import locate, locate_ignore_error, PYLMM_COMMAND, GEMMA_COMMAND, PLINK_COMMAND
+from utility.external import shell
+from base.webqtlConfig import TMPDIR, GENERATED_TEXT_DIR
 
 class MarkerRegression(object):
 
@@ -304,22 +299,14 @@ class MarkerRegression(object):
         included_markers, p_values = self.parse_gemma_output()
         
         self.dataset.group.get_specified_markers(markers = included_markers)
-        
-        #for marker in self.dataset.group.markers.markers:
-        #    if marker['name'] not in included_markers:
-        #        print("marker:", marker)
-        #        self.dataset.group.markers.markers.remove(marker)
-        #        #del self.dataset.group.markers.markers[marker]
-        
         self.dataset.group.markers.add_pvalues(p_values)
-
         return self.dataset.group.markers.markers
 
-
     def parse_gemma_output(self):
         included_markers = []
         p_values = []
-        with open("/home/zas1024/gene/web/gemma/output/{}_output.assoc.txt".format(self.dataset.group.name)) as output_file:
+        # Use a temporary file name here!
+        with open(webqtlConfig.GENERATED_TEXT_DIR+"/{}_output.assoc.txt".format(self.dataset.group.name)) as output_file:
             for line in output_file:
                 if line.startswith("chr"):
                     continue
@@ -332,37 +319,18 @@ class MarkerRegression(object):
 
     def gen_pheno_txt_file(self):
         """Generates phenotype file for GEMMA"""
-        
-        #with open("/home/zas1024/gene/web/gemma/tmp_pheno/{}.txt".format(filename), "w") as outfile:
-        #    for sample, i in enumerate(self.samples):
-        #        print("sample:" + str(i))
-        #        print("self.vals[i]:" + str(self.vals[sample]))
-        #        outfile.write(str(i) + "\t" + str(self.vals[sample]) + "\n")
-                
-        with open("/home/zas1024/gene/web/gemma/{}.fam".format(self.dataset.group.name), "w") as outfile:
+        with open(webqtlConfig.GENERATED_TEXT_DIR+"{}.fam".format(self.dataset.group.name), "w") as outfile:
             for i, sample in enumerate(self.samples):
                 outfile.write(str(sample) + " " + str(sample) + " 0 0 0 " + str(self.vals[i]) + "\n")
-
-    #def gen_plink_for_gemma(self, filename):
-    #    
-    #    make_bed = "/home/zas1024/plink/plink --file /home/zas1024/plink/%s --noweb --no-fid --no-parents --no-sex --no-pheno --pheno %s%s.txt --out %s%s --make-bed" % (webqtlConfig.HTMLPATH,
-    #                                                                                                                                             webqtlConfig.HTMLPATH,
-    #                                                                                                                                             self.dataset.group.name,
-    #                                                                                                                                             webqtlConfig.TMPDIR,
-    #                                                                                                                                             filename,
-    #                                                                                                                                             webqtlConfig.TMPDIR,
-    #                                                                                                                                             filename)
-    #
-    #
     
     def run_rqtl_plink(self):
-        os.chdir("/home/zas1024/plink")
+        # os.chdir("") never do this inside a webserver!!
         
         output_filename = webqtlUtil.genRandStr("%s_%s_"%(self.dataset.group.name, self.this_trait.name))
         
         self.gen_pheno_txt_file_plink(pheno_filename = output_filename)
         
-        rqtl_command = './plink --noweb --ped %s.ped --no-fid --no-parents --no-sex --no-pheno --map %s.map --pheno %s/%s.txt --pheno-name %s --maf %s --missing-phenotype -9999 --out %s%s --assoc ' % (self.dataset.group.name, self.dataset.group.name, webqtlConfig.TMPDIR, plink_output_filename, self.this_trait.name, self.maf, webqtlConfig.TMPDIR, plink_output_filename)
+        rqtl_command = './plink --noweb --ped %s.ped --no-fid --no-parents --no-sex --no-pheno --map %s.map --pheno %s/%s.txt --pheno-name %s --maf %s --missing-phenotype -9999 --out %s%s --assoc ' % (self.dataset.group.name, self.dataset.group.name, TMPDIR, plink_output_filename, self.this_trait.name, self.maf, TMPDIR, plink_output_filename)
         
         os.system(rqtl_command)
         
@@ -419,10 +387,11 @@ class MarkerRegression(object):
         calc_genoprob   = ro.r["calc.genoprob"]         # Map the calc.genoprob function
         read_cross      = ro.r["read.cross"]            # Map the read.cross function
         write_cross     = ro.r["write.cross"]           # Map the write.cross function
-        GENOtoCSVR      = ro.r["GENOtoCSVR"]            # Map the GENOtoCSVR function
+        GENOtoCSVR      = ro.r["GENOtoCSVR"]            # Map the local GENOtoCSVR function
 
-        genofilelocation  = webqtlConfig.HTMLPATH + "genotypes/" + self.dataset.group.name + ".geno"
-        crossfilelocation = webqtlConfig.HTMLPATH + "genotypes/" + self.dataset.group.name + ".cross"
+        crossname = self.dataset.group.name
+        genofilelocation  = locate(crossname + ".geno", "genotype")
+        crossfilelocation = TMPDIR + crossname + ".cross"
 
         #print("Conversion of geno to cross at location:", genofilelocation, " to ", crossfilelocation)
 
@@ -449,7 +418,7 @@ class MarkerRegression(object):
             #print("Pair scan results:", result_data_frame)
 
             self.pair_scan_filename = webqtlUtil.genRandStr("scantwo_") + ".png"
-            png(file=webqtlConfig.TMPDIR+self.pair_scan_filename)
+            png(file=TMPDIR+self.pair_scan_filename)
             plot(result_data_frame)
             dev_off()
             
@@ -559,8 +528,8 @@ class MarkerRegression(object):
         
         self.gen_pheno_txt_file_plink(pheno_filename = plink_output_filename)
         
-        plink_command = PLINK_COMMAND + ' --noweb --bed %s/%s.bed --bim %s/%s.bim --fam %s/%s.fam --no-fid --no-parents --no-sex --no-pheno --pheno %s%s.txt --pheno-name %s --maf %s --missing-phenotype -9999 --out %s%s --assoc ' % (PLINK_PATH, self.dataset.group.name, PLINK_PATH, self.dataset.group.name, PLINK_PATH, self.dataset.group.name, webqtlConfig.TMPDIR, plink_output_filename, self.this_trait.name, self.maf, webqtlConfig.TMPDIR, plink_output_filename)
-        #print("plink_command:", plink_command)        
+        plink_command = PLINK_COMMAND + ' --noweb --ped %s/%s.ped --no-fid --no-parents --no-sex --no-pheno --map %s/%s.map --pheno %s%s.txt --pheno-name %s --maf %s --missing-phenotype -9999 --out %s%s --assoc ' % (PLINK_PATH, self.dataset.group.name, PLINK_PATH, self.dataset.group.name, TMPDIR, plink_output_filename, self.this_trait.name, self.maf, TMPDIR, plink_output_filename)
+        print("plink_command:", plink_command)        
 
         os.system(plink_command)
 
@@ -581,7 +550,7 @@ class MarkerRegression(object):
 
     def gen_pheno_txt_file_plink(self, pheno_filename = ''):
         ped_sample_list = self.get_samples_from_ped_file()	
-        output_file = open("%s%s.txt" % (webqtlConfig.TMPDIR, pheno_filename), "wb")
+        output_file = open("%s%s.txt" % (TMPDIR, pheno_filename), "wb")
         header = 'FID\tIID\t%s\n' % self.this_trait.name
         output_file.write(header)
     
@@ -616,7 +585,7 @@ class MarkerRegression(object):
         
     def gen_pheno_txt_file_rqtl(self, pheno_filename = ''):
         ped_sample_list = self.get_samples_from_ped_file()	
-        output_file = open("%s%s.txt" % (webqtlConfig.TMPDIR, pheno_filename), "wb")
+        output_file = open("%s%s.txt" % (TMPDIR, pheno_filename), "wb")
         header = 'FID\tIID\t%s\n' % self.this_trait.name
         output_file.write(header)
     
@@ -762,7 +731,7 @@ class MarkerRegression(object):
     
         threshold_p_value = 0.01
     
-        result_fp = open("%s%s.qassoc"% (webqtlConfig.TMPDIR, output_filename), "rb")
+        result_fp = open("%s%s.qassoc"% (TMPDIR, output_filename), "rb")
         
         header_line = result_fp.readline()# read header line
         line = result_fp.readline()
@@ -872,9 +841,7 @@ class MarkerRegression(object):
                 Redis.expire(key, 60*60)
     
                 command = PYLMM_COMMAND+' --key {} --species {}'.format(key,"other")
-    
-                os.system(command)
-    
+                shell(command)
                 
                 json_results = Redis.blpop("pylmm:results:" + temp_uuid, 45*60)
                 results = json.loads(json_results[1])
@@ -949,12 +916,11 @@ class MarkerRegression(object):
             Redis.expire(key, 60*60)
             print("before printing command")
 
-            command = PYLMM_COMMAND + ' --key {} --species {}'.format(key,
-                                                                                                                    "other")
+            command = PYLMM_COMMAND + ' --key {} --species {}'.format(key, "other")
             print("command is:", command)
             print("after printing command")
 
-            os.system(command)
+            shell(command)
 
             #t_stats, p_values = lmm.run(key)
             #lmm.run(key)
@@ -991,8 +957,7 @@ class MarkerRegression(object):
 
     #def gen_human_results(self, pheno_vector, tempdata):
     def gen_human_results(self, pheno_vector, key, temp_uuid):
-        file_base = os.path.join(webqtlConfig.PYLMM_PATH, self.dataset.group.name)
-        print("file_base:", file_base)
+        file_base = locate(self.dataset.group.name,"mapping")
 
         plink_input = input.plink(file_base, type='b')
         input_file_name = os.path.join(webqtlConfig.SNP_PATH, self.dataset.group.name + ".snps.gz")
@@ -1084,7 +1049,11 @@ class MarkerRegression(object):
         return trimmed_genotype_data
     
 def create_snp_iterator_file(group):
-    plink_file_base = os.path.join(webqtlConfig.PYLMM_PATH, group)
+    """ 
+    This function is only called by main below
+    """
+    raise Exception("Paths are undefined here")
+    plink_file_base = os.path.join(TMPDIR, group)
     plink_input = input.plink(plink_file_base, type='b')
     
     data = dict(plink_input = list(plink_input),
@@ -1145,5 +1114,3 @@ def get_markers_from_csv(included_markers, p_values, group_name):
     
 if __name__ == '__main__':
     import cPickle as pickle
-    import gzip
-    create_snp_iterator_file("HLC")
diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
index e0007455..4460c06d 100644
--- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py
+++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
@@ -38,20 +38,11 @@ from htmlgen import HTMLgen2 as HT
 
 from base import webqtlConfig
 from base.GeneralObject import GeneralObject
-#from base.webqtlTrait import webqtlTrait
-#from base.templatePage import templatePage
 from utility import webqtlUtil
 from utility import helper_functions
 from utility import Plot
-#from utility.THCell import THCell
-#from utility.TDCell import TDCell
 from wqflask.interval_analyst import GeneUtil
-
-#from dbFunction import webqtlDatabaseFunction
-
-#import logging
-#logging.basicConfig(filename="/tmp/gn_leiyan.log", level=logging.INFO)
-#_log = logging.getLogger("gn\web\webqtl\intervalMapping\IntervalMappingPage.py")
+from base.webqtlConfig import TMPDIR, GENERATED_TEXT_DIR, GENERATED_IMAGE_DIR
 
 #########################################
 #      Inteval Mapping Plot Page
@@ -178,8 +169,8 @@ class MarkerRegression(object):
         self.species = start_vars['species']
 
         #Needing for form submission when doing single chr mapping or remapping after changing options
-        self.vals = start_vars['vals'] 
-        self.mapping_method = start_vars['mapping_method'] 
+        self.vals = start_vars['vals']
+        self.mapping_method = start_vars['mapping_method']
         if self.mapping_method == "rqtl_geno":
             self.mapmethod_rqtl_geno = start_vars['method']
             self.mapmodel_rqtl_geno = start_vars['model']
@@ -232,7 +223,7 @@ class MarkerRegression(object):
                 self.significant = start_vars['significant']
         else:
             self.nperm = 0
-           
+
         if 'bootCheck' in start_vars.keys():
             self.bootChecked = start_vars['bootCheck']
         else:
@@ -308,7 +299,7 @@ class MarkerRegression(object):
         if 'showSNP' in start_vars.keys():
             self.SNPChecked = start_vars['showSNP']
         else:
-            self.SNPChecked = False  
+            self.SNPChecked = False
         if 'showGenes' in start_vars.keys():
             self.geneChecked = start_vars['showGenes']
         else:
@@ -321,7 +312,7 @@ class MarkerRegression(object):
             self.endMb = float(start_vars['endMb'])
         except:
             self.endMb = -1
-        try: 
+        try:
             self.lrsMax = float(start_vars['lrsMax'])
         except:
             self.lrsMax = 0
@@ -363,7 +354,7 @@ class MarkerRegression(object):
             self.ChrList.append((indChr.name, i))
 
 
-        
+
         self.ChrLengthMbList = g.db.execute("""
                 Select
                         Length from Chr_Length, InbredSet
@@ -517,20 +508,19 @@ class MarkerRegression(object):
             chrName = self.selectedChr
             # Draw the genes for this chromosome / region of this chromosome
             webqtldatabase = self.dataset.name
-        
+
             if self.dataset.group.species == "mouse":
-               self.geneCol = GeneUtil.loadGenes(chrName, self.diffCol, self.startMb, self.endMb, webqtldatabase, "mouse")
+                self.geneCol = GeneUtil.loadGenes(chrName, self.diffCol, self.startMb, self.endMb, webqtldatabase, "mouse")
             elif self.dataset.group.species == "rat":
                self.geneCol = GeneUtil.loadGenes(chrName, self.diffCol, self.startMb, self.endMb, webqtldatabase, "rat")
 
-        
             if self.geneCol and self.intervalAnalystChecked:
                #######################################################################
                #Nick use GENEID as RefGene to get Literature Correlation Informations#
                #For Interval Mapping, Literature Correlation isn't useful, so skip it#
                #through set GENEID is None                                           #
                #######################################################################
-               
+
                #GENEID = fd.formdata.getvalue('GeneId') or None
                GENEID = None
 
@@ -538,7 +528,7 @@ class MarkerRegression(object):
                self.geneTable(self.geneCol, GENEID)
                #geneTable = self.geneTable(self.geneCol, GENEID)
                #geneTableContainer.append(geneTable)
-               
+
                #mainfmName = webqtlUtil.genRandStr("fm_")
                #tableForm = HT.Form(cgi=os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data', name=mainfmName, submit=HT.Input(type='hidden'))
                #tableForm.append(HT.Input(name='FormID', value='', type='hidden'))
@@ -553,22 +543,22 @@ class MarkerRegression(object):
         #else:
         showLocusForm = ""
         intCanvas = pid.PILCanvas(size=(self.graphWidth, self.graphHeight))
-        gifmap = self.plotIntMapping(intCanvas, startMb = self.startMb, endMb = self.endMb, showLocusForm= showLocusForm)    
+        gifmap = self.plotIntMapping(intCanvas, startMb = self.startMb, endMb = self.endMb, showLocusForm= showLocusForm)
 
         self.gifmap = gifmap.__str__()
         #print("GIFMAP:", gifmap.__str__())
 
         self.filename= webqtlUtil.genRandStr("Itvl_")
-        intCanvas.save(os.path.join(webqtlConfig.IMGDIR, self.filename), format='jpeg')
+        intCanvas.save(os.path.join(webqtlConfig.GENERATED_IMAGE_DIR, self.filename), format='jpeg')
         intImg=HT.Image('/image/'+self.filename+'.png', border=0, usemap='#WebQTLImageMap')
 
         #Scales plot differently for high resolution
         if self.draw2X:
             intCanvasX2 = pid.PILCanvas(size=(self.graphWidth*2,self.graphHeight*2))
             gifmapX2 = self.plotIntMapping(intCanvasX2, startMb = self.startMb, endMb = self.endMb, showLocusForm= showLocusForm, zoom=2)
-            intCanvasX2.save(os.path.join(webqtlConfig.IMGDIR, self.filename+"X2"), format='png')
+            intCanvasX2.save(os.path.join(webqtlConfig.GENERATED_IMAGE_DIR, self.filename+"X2"), format='png')
             #DLintImgX2=HT.Href(text='Download',url = '/image/'+self.filename+'X2.png', Class='smallsize', target='_blank')
- 
+
         #textUrl = self.writeQTL2Text(fd, self.filename)
 
         ################################################################
@@ -598,7 +588,7 @@ class MarkerRegression(object):
             showLocusForm.append(intImg)
         else:
             showLocusForm = intImg
-        
+
         if self.permChecked and self.nperm > 0 and not self.multipleInterval and 0 < self.nperm:
             self.perm_filename = self.drawPermutationHistogram()
             #perm_text_file = self.permutationTextFile()
@@ -668,7 +658,7 @@ class MarkerRegression(object):
             TD_LR.append(HT.Blockquote(tableForm))
 
         self.body = TD_LR
-       
+
         #self.dict['body'] = TD_LR
         #self.dict['title'] = "Mapping"
 
@@ -684,7 +674,7 @@ class MarkerRegression(object):
 
         fpText.write("Source: WebQTL, The GeneNetwork (%s)\n" % webqtlConfig.PORTADDR)
         #
-        fpText.write("Site: %s\n" % webqtlConfig.SITENAME)
+        fpText.write("Site: GN\n")
         fpText.write("Page: Map Viewer\n")
         fpText.write(time.strftime("Date and Time (US Center): %b %d, %Y at %I.%M %p\n", time.localtime()))
         fpText.write("Trait ID: %s\n" % self.this_trait.name)
@@ -859,7 +849,7 @@ class MarkerRegression(object):
         BootCoord = []
         i = 0
         startX = xLeftOffset
-        
+
         if self.selectedChr == -1: #ZS: If viewing full genome/all chromosomes
             for j, _chr in enumerate(self.genotype):
                 BootCoord.append( [])
@@ -882,8 +872,8 @@ class MarkerRegression(object):
                         else:
                             Xc = startX + (_locus.cM-_chr[0].cM)*plotXScale
                         BootCoord[-1].append([Xc, self.bootResult[i]])
-                    i += 1      
-                
+                    i += 1
+
         #reduce bootResult
         if self.selectedChr > -1:
             maxBootBar = 80.0
@@ -1412,7 +1402,7 @@ class MarkerRegression(object):
             if _strains[ii] in self.dataset.group.samplelist:
                 temp = GeneralObject(name=_strains[ii], value=_val)
                 smd.append(temp)
-            
+
 
         smd.sort(lambda A, B: cmp(A.value, B.value))
         smd.reverse()
@@ -1567,14 +1557,14 @@ class MarkerRegression(object):
                     firstGene = 0
                 else:
                     lastGene = 0
-                     
+
         for j, _geno in enumerate (self.genotype[0][1].genotype):
 
             plotbxd=0
             for item in smd:
                 if item.name == samplelist[j]:
-                    plotbxd=1    
-                    
+                    plotbxd=1
+
             if (plotbxd == 1):
 
                 ind = 0
@@ -1621,28 +1611,28 @@ class MarkerRegression(object):
 
         currentChromosome = self.genotype[0].name
         i = 0
-        
+
         paddingTop = yTopOffset
         ucscPaddingTop = paddingTop + self.WEBQTL_BAND_HEIGHT + self.BAND_SPACING
         ensemblPaddingTop = ucscPaddingTop + self.UCSC_BAND_HEIGHT + self.BAND_SPACING
-        
+
         if zoom == 1:
             for pixel in range(xLeftOffset, xLeftOffset + plotWidth, pixelStep):
-    
+
                 calBase = self.kONE_MILLION*(startMb + (endMb-startMb)*(pixel-xLeftOffset-0.0)/plotWidth)
-    
+
                 xBrowse1 = pixel
                 xBrowse2 = min(xLeftOffset + plotWidth, (pixel + pixelStep - 1))
-    
+
                 WEBQTL_COORDS = "%d, %d, %d, %d" % (xBrowse1, paddingTop, xBrowse2, (paddingTop+self.WEBQTL_BAND_HEIGHT))
                 bandWidth = xBrowse2 - xBrowse1
                 WEBQTL_HREF = "javascript:rangeView('%s', %f, %f)" % (self.selectedChr - 1, max(0, (calBase-webqtlZoomWidth))/1000000.0, (calBase+webqtlZoomWidth)/1000000.0)
-    
+
                 WEBQTL_TITLE = "Click to view this section of the genome in WebQTL"
                 gifmap.areas.append(HT.Area(shape='rect',coords=WEBQTL_COORDS,href=WEBQTL_HREF, title=WEBQTL_TITLE))
                 canvas.drawRect(xBrowse1, paddingTop, xBrowse2, (paddingTop + self.WEBQTL_BAND_HEIGHT), edgeColor=self.CLICKABLE_WEBQTL_REGION_COLOR, fillColor=self.CLICKABLE_WEBQTL_REGION_COLOR)
                 canvas.drawLine(xBrowse1, paddingTop, xBrowse1, (paddingTop + self.WEBQTL_BAND_HEIGHT), color=self.CLICKABLE_WEBQTL_REGION_OUTLINE_COLOR)
-    
+
                 UCSC_COORDS = "%d, %d, %d, %d" %(xBrowse1, ucscPaddingTop, xBrowse2, (ucscPaddingTop+self.UCSC_BAND_HEIGHT))
                 if self.dataset.group.species == "mouse":
                     UCSC_HREF = "http://genome.ucsc.edu/cgi-bin/hgTracks?db=%s&position=chr%s:%d-%d&hgt.customText=%s/snp/chr%s" % (self._ucscDb, self.selectedChr, max(0, calBase-flankingWidthInBases), calBase+flankingWidthInBases, webqtlConfig.PORTADDR, self.selectedChr)
@@ -1652,7 +1642,7 @@ class MarkerRegression(object):
                 gifmap.areas.append(HT.Area(shape='rect',coords=UCSC_COORDS,href=UCSC_HREF, title=UCSC_TITLE))
                 canvas.drawRect(xBrowse1, ucscPaddingTop, xBrowse2, (ucscPaddingTop+self.UCSC_BAND_HEIGHT), edgeColor=self.CLICKABLE_UCSC_REGION_COLOR, fillColor=self.CLICKABLE_UCSC_REGION_COLOR)
                 canvas.drawLine(xBrowse1, ucscPaddingTop, xBrowse1, (ucscPaddingTop+self.UCSC_BAND_HEIGHT), color=self.CLICKABLE_UCSC_REGION_OUTLINE_COLOR)
-    
+
                 ENSEMBL_COORDS = "%d, %d, %d, %d" %(xBrowse1, ensemblPaddingTop, xBrowse2, (ensemblPaddingTop+self.ENSEMBL_BAND_HEIGHT))
                 if self.dataset.group.species == "mouse":
                     ENSEMBL_HREF = "http://www.ensembl.org/Mus_musculus/contigview?highlight=&chr=%s&vc_start=%d&vc_end=%d&x=35&y=12" % (self.selectedChr, max(0, calBase-flankingWidthInBases), calBase+flankingWidthInBases)
@@ -1767,7 +1757,7 @@ class MarkerRegression(object):
             ChrAInfo = []
             preLpos = -1
             distinctCount = 0.0
-            
+
             #if len(self.genotype) > 1:
             if self.selectedChr == -1: #ZS: If viewing full genome/all chromosomes
                 for i, _chr in enumerate(self.genotype):
@@ -1810,7 +1800,7 @@ class MarkerRegression(object):
             offsetA = -stepA
             lineColor = pid.lightblue
             startPosX = xLeftOffset
-            
+
             for j, ChrInfo in enumerate(ChrAInfo):
                 preLpos = -1
                 for i, item in enumerate(ChrInfo):
@@ -1878,7 +1868,7 @@ class MarkerRegression(object):
             # lodm = self.LODFACTOR
         # else:
             # lodm = 1.0
- 
+
         #ZS: This is a mess, but I don't know a better way to account for different mapping methods returning results in different formats + the option to change between LRS and LOD
         if self.lrsMax <= 0:  #sliding scale
             if "lrs_value" in self.qtlresults[0]:
@@ -1891,7 +1881,7 @@ class MarkerRegression(object):
                 else:
                     if self.permChecked and self.nperm > 0 and not self.multipleInterval:
                         self.significant = min(self.significant, webqtlConfig.MAXLRS)
-                        self.suggestive = min(self.suggestive, webqtlConfig.MAXLRS)                    
+                        self.suggestive = min(self.suggestive, webqtlConfig.MAXLRS)
                     else:
                         pass
             else:
@@ -1904,10 +1894,10 @@ class MarkerRegression(object):
                 else:
                     if self.permChecked and self.nperm > 0 and not self.multipleInterval:
                         self.significant = min(self.significant, webqtlConfig.MAXLRS)
-                        self.suggestive = min(self.suggestive, webqtlConfig.MAXLRS)  
+                        self.suggestive = min(self.suggestive, webqtlConfig.MAXLRS)
                     else:
                         pass
-                        
+
             if self.permChecked and self.nperm > 0 and not self.multipleInterval:
                 LRS_LOD_Max = max(self.significant, LRS_LOD_Max)
 
@@ -1924,7 +1914,7 @@ class MarkerRegression(object):
             LRSScale = 2.5
         else:
             LRSScale = 1.0
-           
+
         LRSAxisList = Plot.frange(LRSScale, LRS_LOD_Max, LRSScale)
         #make sure the user's value appears on the y-axis
         #update by NL 6-21-2011: round the LOD value to 100 when LRS_LOD_Max is equal to 460
@@ -1954,7 +1944,7 @@ class MarkerRegression(object):
 
             #"Significant" and "Suggestive" Drawing Routine
             # ======= Draw the thick lines for "Significant" and "Suggestive" =====  (crowell: I tried to make the SNPs draw over these lines, but piddle wouldn't have it...)
-            
+
             #ZS: I don't know if what I did here with this inner function is clever or overly complicated, but it's the only way I could think of to avoid duplicating the code inside this function
             def add_suggestive_significant_lines_and_legend(start_pos_x, chr_length_dist):
                 rightEdge = int(start_pos_x + chr_length_dist*plotXScale - self.SUGGESTIVE_WIDTH/1.5)
@@ -1977,13 +1967,13 @@ class MarkerRegression(object):
 
                 start_pos_x +=  (chr_length_dist+self.GraphInterval)*plotXScale
                 return start_pos_x
-            
+
             for i, _chr in enumerate(self.genotype):
                 if self.selectedChr != -1:
                     if _chr.name == self.ChrList[self.selectedChr][0]:
                         startPosX = add_suggestive_significant_lines_and_legend(startPosX, self.ChrLengthDistList[0])
                         break
-                    else: 
+                    else:
                         continue
                 else:
                     startPosX = add_suggestive_significant_lines_and_legend(startPosX, self.ChrLengthDistList[i])
@@ -1998,7 +1988,7 @@ class MarkerRegression(object):
             #else:
             #    dominanceMax = -1
             lrsEdgeWidth = 2
-            
+
         if zoom == 2:
             lrsEdgeWidth = 2 * lrsEdgeWidth
 
@@ -2019,7 +2009,7 @@ class MarkerRegression(object):
             if qtlresult['chr'] != previous_chr and self.selectedChr == -1:
                 if self.manhattan_plot != True:
                     canvas.drawPolygon(LRSCoordXY,edgeColor=thisLRSColor,closed=0, edgeWidth=lrsEdgeWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
-                    
+
                 if not self.multipleInterval and self.additiveChecked:
                     plusColor = self.ADDITIVE_COLOR_POSITIVE
                     minusColor = self.ADDITIVE_COLOR_NEGATIVE
@@ -2049,7 +2039,7 @@ class MarkerRegression(object):
                                     canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
                                 else:
                                     canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
-                    
+
                 LRSCoordXY = []
                 AdditiveCoordXY = []
                 previous_chr = qtlresult['chr']
@@ -2062,7 +2052,7 @@ class MarkerRegression(object):
 
             #startPosX += (self.ChrLengthDistList[j]+self.GraphInterval)*plotXScale
 
-            #for j, _chr in enumerate(self.genotype):   
+            #for j, _chr in enumerate(self.genotype):
             #ZS: This is beause the chromosome value stored in qtlresult['chr'] can be (for example) either X or 20 depending upon the mapping method/scale used
             if self.plotScale == "physic":
                 this_chr = str(self.ChrList[self.selectedChr][0])
@@ -2126,7 +2116,7 @@ class MarkerRegression(object):
 
         if self.manhattan_plot != True:
             canvas.drawPolygon(LRSCoordXY,edgeColor=thisLRSColor,closed=0, edgeWidth=lrsEdgeWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
-            
+
         if not self.multipleInterval and self.additiveChecked:
             plusColor = self.ADDITIVE_COLOR_POSITIVE
             minusColor = self.ADDITIVE_COLOR_NEGATIVE
@@ -2156,7 +2146,7 @@ class MarkerRegression(object):
                             canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
                         else:
                             canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
-                    
+
         if not self.multipleInterval and INTERCROSS and self.dominanceChecked:
             plusColor = self.DOMINANCE_COLOR_POSITIVE
             minusColor = self.DOMINANCE_COLOR_NEGATIVE
@@ -2186,7 +2176,7 @@ class MarkerRegression(object):
                             canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
                         else:
                             canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
-                
+
 
         ###draw additive scale
         if not self.multipleInterval and self.additiveChecked:
@@ -2222,7 +2212,7 @@ class MarkerRegression(object):
         if zoom == 2:
             fontZoom = 1.5
             yTopOffset += 30
-        
+
         #calculate plot scale
         if self.plotScale != 'physic':
             self.ChrLengthDistList = self.ChrLengthCMList
@@ -2589,13 +2579,13 @@ class MarkerRegression(object):
             perm_output = [value/4.16 for value in self.perm_output]
         else:
             perm_output = self.perm_output
-            
+
         Plot.plotBar(myCanvas, perm_output, XLabel=self.LRS_LOD, YLabel='Frequency', title=' Histogram of Permutation Test')
         filename= webqtlUtil.genRandStr("Reg_")
-        myCanvas.save(webqtlConfig.IMGDIR+filename, format='gif')
-        
+        myCanvas.save(GENERATED_IMAGE_DIR+filename, format='gif')
+
         return filename
-        
+
         # img=HT.Image('/image/'+filename+'.gif',border=0,alt='Histogram of Permutation Test')
 
         # self.suggestive = self.perm_output[int(self.nperm*0.37-1)]
@@ -2609,9 +2599,9 @@ class MarkerRegression(object):
         # permutation.append(HT.TR(HT.TD(img)),
                            # HT.TR(HT.TD('')),
                            # HT.TR(HT.TD('Total of %d permutations'%self.nperm)))
-        
+
         # return permutation
-    
+
     def permutationTextFile(self):
         filename= webqtlUtil.genRandStr("Reg_")
         fpText = open('%s.txt' % (webqtlConfig.TMPDIR+filename), 'wb')
@@ -2624,12 +2614,12 @@ class MarkerRegression(object):
                               '&nbsp;&nbsp;&nbsp;&nbsp;Significant LRS =%3.2f\n'%self.significant,
                               HT.BR(),
                               '&nbsp;&nbsp;&nbsp;&nbsp;Highly Significant LRS =%3.2f\n' % self.highlysignificant)
-        
+
         for lrs_value in self.perm_output:
             fpText.write(str(lrs_value) + "\n")
-        
+
         textUrl = HT.Href(text = 'Download Permutation Results', url= '/tmp/'+filename+'.txt', target = "_blank", Class='fs12 fwn')
-        
+
         return textUrl
 
     def geneTable(self, geneCol, refGene=None):
@@ -3039,4 +3029,4 @@ class MarkerRegression(object):
 
         sortby = ("", "")
 
-        return sortby
\ No newline at end of file
+        return sortby
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index a57bfffe..9941a4d3 100755
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -24,9 +24,8 @@ from flask import Flask, g
 from MySQLdb import escape_string as escape
 
 # Instead of importing HT we're going to build a class below until we can eliminate it
-from htmlgen import HTMLgen2 as HT
+# from htmlgen import HTMLgen2 as HT
 
-from base import webqtlConfig
 from utility.benchmark import Bench
 from base.data_set import create_dataset
 from base.trait import GeneralTrait
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 156510bb..074c78bf 100755
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -16,7 +16,6 @@ from base import webqtlConfig
 from base import webqtlCaseData
 from wqflask.show_trait.SampleList import SampleList
 from utility import webqtlUtil, Plot, Bunch, helper_functions
-from utility.tools import pylmm_command, plink_command
 from base.trait import GeneralTrait
 from base import data_set
 from dbFunction import webqtlDatabaseFunction
@@ -24,8 +23,8 @@ from basicStatistics import BasicStatisticsFunctions
 
 from pprint import pformat as pf
 
-PYLMM_PATH,PYLMM_COMMAND = pylmm_command()
-PLINK_PATH,PLINK_COMMAND = plink_command()
+from utility.tools import flat_files
+MAPPING_PATH = flat_files("mapping")
 
 ###############################################
 #
@@ -34,8 +33,6 @@ PLINK_PATH,PLINK_COMMAND = plink_command()
 #
 ##############################################
 
-
-
 class ShowTrait(object):
 
     def __init__(self, kw):
@@ -163,14 +160,14 @@ class ShowTrait(object):
     def get_mapping_methods(self):
         '''Only display mapping methods when the dataset group's genotype file exists'''
         def check_plink_gemma():
-            if (os.path.isfile(PLINK_PATH+"/"+self.dataset.group.name+".bed") and
-                os.path.isfile(PLINK_PATH+"/"+self.dataset.group.name+".map")):
+            if (os.path.isfile(MAPPING_PATH+"/"+self.dataset.group.name+".bed") and
+                os.path.isfile(MAPPING_PATH+"/"+self.dataset.group.name+".map")):
                 return True
             else:
                 return False
 
         def check_pylmm_rqtl():
-            if os.path.isfile(webqtlConfig.GENODIR+self.dataset.group.name+".geno") and (os.path.getsize(webqtlConfig.NEWGENODIR+self.dataset.group.name+".json") > 0):
+            if os.path.isfile(webqtlConfig.GENODIR+self.dataset.group.name+".geno") and (os.path.getsize(webqtlConfig.JSON_GENODIR+self.dataset.group.name+".json") > 0):
                 return True
             else:
                 return False
diff --git a/wqflask/wqflask/static/css b/wqflask/wqflask/static/css
deleted file mode 120000
index 9d8c2f68..00000000
--- a/wqflask/wqflask/static/css
+++ /dev/null
@@ -1 +0,0 @@
-../../../web/css
\ No newline at end of file
diff --git a/wqflask/wqflask/static/dbdoc/TODO.md b/wqflask/wqflask/static/dbdoc/TODO.md
deleted file mode 100644
index c0a8bab7..00000000
--- a/wqflask/wqflask/static/dbdoc/TODO.md
+++ /dev/null
@@ -1 +0,0 @@
-TODO: Add all database documentation into this folder
diff --git a/wqflask/wqflask/static/images b/wqflask/wqflask/static/images
deleted file mode 120000
index 12f0f8b5..00000000
--- a/wqflask/wqflask/static/images
+++ /dev/null
@@ -1 +0,0 @@
-../../../web/images
\ No newline at end of file
diff --git a/wqflask/wqflask/static/javascript b/wqflask/wqflask/static/javascript
deleted file mode 120000
index 5f58faf4..00000000
--- a/wqflask/wqflask/static/javascript
+++ /dev/null
@@ -1 +0,0 @@
-../../../web/javascript
\ No newline at end of file
diff --git a/wqflask/wqflask/static/new/css/corr_matrix.css b/wqflask/wqflask/static/new/css/corr_matrix.css
index 495ca28c..cd2b0a80 100755
--- a/wqflask/wqflask/static/new/css/corr_matrix.css
+++ b/wqflask/wqflask/static/new/css/corr_matrix.css
@@ -3,7 +3,7 @@
        -moz-transform: rotate(-90deg);
         -ms-transform: rotate(-90deg);
          -o-transform: rotate(-90deg);
-            trasnform: rotate(-90deg);
+            transform: rotate(-90deg);
               color: #000
               font-size: 22px;
               height: 50px;
diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html
index f25bf9f7..b4fdbd8e 100755
--- a/wqflask/wqflask/templates/base.html
+++ b/wqflask/wqflask/templates/base.html
@@ -151,7 +151,7 @@
         <!--</p>-->
 
         <ul class="footer-links">
-          <li><a href="http://atlas.uthsc.edu/mailman/listinfo/genenetwork" target="_blank">Join the mailing list</a></li>
+          <li><a href="http://listserv.uthsc.edu/mailman/listinfo/genenetwork-dev">Join the mailing list</a></li>
           <!--<li><a href="#">Friend us on facebook</a></li>-->
           <!--<li><a href="#">Follow us on twitter</a></li>-->
         </ul>
diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html
index f92d9984..c1563b9c 100755
--- a/wqflask/wqflask/templates/collections/view.html
+++ b/wqflask/wqflask/templates/collections/view.html
@@ -55,6 +55,18 @@
                     <input type="submit" class="btn btn-primary" value="WGCNA Analysis" />
                 </div>
             </form>
+            <form action="/ctl_setup" method="post">
+                {% if uc %}
+                <input type="hidden" name="uc_id" id="uc_id" value="{{ uc.id }}" />
+                {% endif %}
+                <input type="hidden" name="trait_list" id="trait_list" value= "
+                {% for this_trait in trait_obs %}
+                    {{ this_trait.name }}:{{ this_trait.dataset.name }},
+                {% endfor %}" >
+                <div class="col-xs-2 controls">
+                    <input type="submit" class="btn btn-primary" value="CTL Analysis" />
+                </div>
+            </form>
             <form action="/heatmap" method="post">
                 {% if uc %}
                 <input type="hidden" name="uc_id" id="uc_id" value="{{ uc.id }}" />
diff --git a/wqflask/wqflask/templates/ctl_results.html b/wqflask/wqflask/templates/ctl_results.html
new file mode 100644
index 00000000..a5cb1c08
--- /dev/null
+++ b/wqflask/wqflask/templates/ctl_results.html
@@ -0,0 +1,47 @@
+{% extends "base.html" %}
+{% block title %}CTL results{% endblock %}
+
+{% block content %} <!-- Start of body -->
+<div class="container">
+  <h1>CTL Results</h1>
+  {{(request.form['trait_list'].split(',')|length -1)}} phenotypes as input<br>
+  <h3>Network Figure</h3>
+  <a href="/tmp/{{ results['imgurl1'] }}">
+      <img alt="Embedded Image" src="data:image/png;base64,
+      {% for elem in results['imgdata1'] -%}
+      {% print("%c"|format(elem)) %}
+      {%- endfor %}
+      " /></a>
+  <h3>CTL/QTL Plots for individual traits</h3>
+  {% for r in range(2, (request.form['trait_list'].split(',')|length +1)) %}
+  <a href="/tmp/{{ results['imgurl' + r|string] }}">
+      <img width=100 height=100 alt="Embedded Image" src="data:image/png;base64,
+      {% for elem in results['imgdata' + r|string] -%}
+      {% print("%c"|format(elem)) %}
+      {%- endfor %}
+      " /></a>
+  {% endfor %}
+  <h3>Tabular results</h3>
+  <table width="80%">
+  <tr><th>trait</th><th>marker</th><th>trait</th><th>LOD</th><th>dCor</th></tr>
+  significant CTL:<br>
+  {% for r in range(results['ctlresult'][0]|length) %}
+    <tr>
+    {% for c in range(results['ctlresult']|length) %}
+      <td>
+      {% if c > 2 %}
+      {{results['ctlresult'][c][r]|float|round(2)}}
+      {% else %}
+      {{results['ctlresult'][c][r]}}
+      {% endif %}
+      </td>
+    {% endfor %}
+    </tr>
+  {% endfor %}
+  </table>
+
+
+
+
+</div>
+{% endblock %}
diff --git a/wqflask/wqflask/templates/ctl_setup.html b/wqflask/wqflask/templates/ctl_setup.html
new file mode 100644
index 00000000..9c0d7bea
--- /dev/null
+++ b/wqflask/wqflask/templates/ctl_setup.html
@@ -0,0 +1,65 @@
+{% extends "base.html" %}
+{% block title %}WCGNA analysis{% endblock %}
+
+{% block content %} <!-- Start of body -->
+<div class="container">
+  <h1>CTL analysis parameters</h1>
+  {{(request.form['trait_list'].split(',')|length -1)}} phenotypes as input
+
+<form action="/ctl_results" method="post" class="form-horizontal">
+	<input type="hidden" name="trait_list" id="trait_list" value= "{{request.form['trait_list']}}">
+
+	<div class="dropdown">
+		<label for="Strategy">Strategy</label>
+		<div class="col-sm-10">
+		<select  name="strategy" id="strategy">
+			<option value="Exact">Exact</option>
+			<option value="Full">Full</option>
+			<option value="Pairwise">Pairwise</option>
+		</select>
+		</div>
+	</div>
+
+	<div class="dropdown">
+		<label for="Permutations">Number of permutation (Used when strategy is Full or Pairwise)</label>
+		<div class="col-sm-10">
+		<select  name="nperm" id="nperm">
+			<option value="100">100</option>
+			<option value="1000" selected="selected">1000</option>
+			<option value="10000">10000</option>
+		</select>
+		</div>
+	</div>
+
+	<div class="dropdown">
+		<label for="Coefficient">Type of correlation coefficient</label>
+		<div class="col-sm-10">
+		<select  name="parametric" id="parametric">
+			<option value="False">Spearman</option>
+			<option value="True">Pearson</option>
+		</select>
+		</div>
+	</div>
+
+
+	<div class="dropdown">
+		<label for="Significance">Significance level</label>
+		<div class="col-sm-10">
+		<select  name="significance" id="significance">
+			<option value="0.1">0.1</option>
+			<option value="0.05" selected="selected">0.05</option>
+			<option value="0.001">0.001</option>
+		</select>
+		</div>
+	</div>
+  <br>
+	<div class="form-group">
+		<div class="col-sm-10">
+			<input type="submit" class="btn btn-primary" value="Run CTL using these settings" />
+		</div>
+	</div>
+
+</form>
+
+</div>
+{% endblock %}
diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html
index 5d658bc7..5cc15682 100755
--- a/wqflask/wqflask/templates/index_page.html
+++ b/wqflask/wqflask/templates/index_page.html
@@ -143,7 +143,7 @@
                         highly expressed genes (15 to 16 log2 units) AND with peak <a href="http://www.genenetwork.org/glossary.html#L" target="_blank">LRS</a>
                         linkage between 23 and 46.</li>
 
-                        <li><b>RIF=mitochondrial</b> searches RNA databases for <a href="http://www.ncbi.nlm.nih.gov/projects/GeneRIF/GeneRIFhelp.html" target="_blank">
+                        <li><b>RIF=mitochondrial</b> searches RNA databases for <a href="https://en.wikipedia.org/wiki/GeneRIF" target="_blank">
                         GeneRIF</a> links.</li>
 
                         <li><b>WIKI=nicotine</b> searches <a href="http://www.genenetwork.org/webqtl/main.py?FormID=geneWiki" target="_blank">
diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html
index d86d981e..978ea55f 100644
--- a/wqflask/wqflask/templates/marker_regression_gn1.html
+++ b/wqflask/wqflask/templates/marker_regression_gn1.html
@@ -144,14 +144,14 @@
             <div class="tab-pane active" id="gn1_map">
               <div class="qtlcharts">
                   {{ gifmap|safe }}
-                  <img src="/static/output/{{ filename }}.jpeg" usemap="#WebQTLImageMap">
+                  <img src="/generated/{{ filename }}.jpeg" usemap="#WebQTLImageMap">
                   {% if additiveChecked|upper == "ON" %}
                   <br>
                   <span style="white-space: nowrap;">A positive additive coefficient (green line) indicates that {{ dataset.group.parlist[1] }} alleles increase trait values. In contrast, a negative additive coefficient (orange line) indicates that {{ dataset.group.parlist[0] }} alleles increase trait values.</span>
                   {% endif %}
                   {% if nperm > 0 and permChecked == "ON" %}
                   <br><br>
-                  <img src="/static/output/{{ perm_filename }}.gif">
+                  <img src="/generated/{{ perm_filename }}.gif">
                   <br><br>
                   Total of {{ nperm }} permutations&nbsp;&nbsp;<a href="javascript:export_perm_data();" target="_blank" >Download Permutation Results</a>
                   <br>
diff --git a/wqflask/wqflask/templates/wgcna_setup.html b/wqflask/wqflask/templates/wgcna_setup.html
index 8ab8c4a0..b4a5730d 100644
--- a/wqflask/wqflask/templates/wgcna_setup.html
+++ b/wqflask/wqflask/templates/wgcna_setup.html
@@ -17,36 +17,36 @@
     {% else %}
  		<form action="/wgcna_results" method="post" class="form-horizontal">
 				<input type="hidden" name="trait_list" id="trait_list" value= "{{request.form['trait_list']}}">
-				<div class="form-group">			
+				<div class="form-group">
 					<label for="SoftThresholds"> Soft threshold: </label>
 					<div class="col-sm-10">
 						<input type="text" class="form-inline" name="SoftThresholds" id="SoftThresholds" value="1,2,3,4,5,6,7,8,9">
 					</div>
 				</div>
-				<div class="form-group">			
+				<div class="form-group">
 					<label for="MinModuleSize"> Minimum module size: </label>
 					<div class="col-sm-10">
 						<input type="text" class="form-inline" name="MinModuleSize" id="MinModuleSize" value="30">
 					</div>
 				</div>
-				<div class="form-group">			
+				<div class="form-group">
 					<label for="TOMtype"> TOMtype: </label>
 					<div class="col-sm-10">
 						<input type="text" class="form-inline" name="TOMtype" id="TOMtype" value="unsigned">
 					</div>
-				</div>			
-				<div class="form-group">			
+				</div>
+				<div class="form-group">
 					<label for="mergeCutHeight"> mergeCutHeight: </label>
 					<div class="col-sm-10">
 						<input type="text" class="form-inline" name="mergeCutHeight" id="mergeCutHeight" value="0.25">
 					</div>
-				</div>			
-				<div class="form-group">			
+				</div>
+				<div class="form-group">
 					<div class="col-sm-10">
 						<input type="submit" class="btn btn-primary" value="Run WGCNA using these settings" />
 					</div>
-				</div>			
-		</form>		
+				</div>
+		</form>
 		{% endif %}
 </div>
 {% endblock %}
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 3cdb9339..bd2fff50 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -30,7 +30,7 @@ import sqlalchemy
 from wqflask import app
 
 from flask import (render_template, request, make_response, Response,
-                   Flask, g, config, jsonify, redirect, url_for)
+                   Flask, g, config, jsonify, redirect, url_for, send_from_directory)
 
 from wqflask import search_results
 from wqflask import gsearch
@@ -48,10 +48,13 @@ from wqflask.correlation_matrix import show_corr_matrix
 from wqflask.correlation import corr_scatter_plot
 
 from wqflask.wgcna import wgcna_analysis
+from wqflask.ctl import ctl_analysis
 
 from utility import temp_data
+from utility.tools import TEMPDIR
 
 from base import webqtlFormData
+from base.webqtlConfig import GENERATED_IMAGE_DIR
 from utility.benchmark import Bench
 
 from pprint import pformat as pf
@@ -96,7 +99,7 @@ def tmp_page(img_path):
     print("img_path:", img_path)
     initial_start_vars = request.form
     print("initial_start_vars:", initial_start_vars)
-    imgfile = open(webqtlConfig.TMPDIR + img_path, 'rb')
+    imgfile = open(GENERATED_IMAGE_DIR + img_path, 'rb')
     imgdata = imgfile.read()
     imgB64 = imgdata.encode("base64")
     bytesarray = array.array('B', imgB64)
@@ -172,6 +175,10 @@ def docedit():
     doc = docs.Docs(request.args['entry'])
     return render_template("docedit.html", **doc.__dict__)
 
+@app.route('/generated/<filename>')
+def generated_file(filename):
+    return send_from_directory(GENERATED_IMAGE_DIR,filename)
+
 @app.route("/help")
 def help():
     doc = docs.Docs("help")
@@ -190,6 +197,18 @@ def wcgna_results():
     result = wgcna.process_results(wgcnaA)                        # After the analysis is finished store the result
     return render_template("wgcna_results.html", **result)        # Display them using the template
 
+@app.route("/ctl_setup", methods=('POST',))
+def ctl_setup():
+    print("In ctl, request.form is:", request.form)             # We are going to get additional user input for the analysis
+    return render_template("ctl_setup.html", **request.form)          # Display them using the template
+
+@app.route("/ctl_results", methods=('POST',))
+def ctl_results():
+    print("In ctl, request.form is:", request.form)
+    ctl = ctl_analysis.CTL()                                  # Start R, load the package and pointers and create the analysis
+    ctlA = ctl.run_analysis(request.form)                     # Start the analysis, a ctlA object should be a separate long running thread
+    result = ctl.process_results(ctlA)                        # After the analysis is finished store the result
+    return render_template("ctl_results.html", **result)      # Display them using the template
 
 @app.route("/news")
 def news_route():
@@ -446,7 +465,7 @@ def marker_regression_page():
             print("img_path:", img_path)
             initial_start_vars = request.form
             print("initial_start_vars:", initial_start_vars)
-            imgfile = open('/home/zas1024/tmp/' + img_path, 'rb')
+            imgfile = open(TEMPDIR + '/' + img_path, 'rb')
             imgdata = imgfile.read()
             imgB64 = imgdata.encode("base64")
             bytesarray = array.array('B', imgB64)
@@ -475,7 +494,7 @@ def export_pdf():
     svg_xml = request.form.get("data", "Invalid data")
     print("svg_xml:", svg_xml)
     filename = request.form.get("filename", "interval_map_pdf")
-    filepath = "/home/zas1024/gene/wqflask/output/"+filename
+    filepath = GENERATED_IMAGE_DIR+filename
     pdf_file = cairosvg.svg2pdf(bytestring=svg_xml)
     response = Response(pdf_file, mimetype="application/pdf")
     response.headers["Content-Disposition"] = "attachment; filename=%s"%filename
diff --git a/wqflask/wqflask/wgcna/wgcna_analysis.py b/wqflask/wqflask/wgcna/wgcna_analysis.py
index 9e9f41bc..880a1cb2 100644
--- a/wqflask/wqflask/wgcna/wgcna_analysis.py
+++ b/wqflask/wqflask/wgcna/wgcna_analysis.py
@@ -6,7 +6,7 @@ import scipy as sp                            # SciPy
 import rpy2.robjects as ro                    # R Objects
 import rpy2.rinterface as ri
 
-from base import webqtlConfig                 # For paths and stuff
+from base.webqtlConfig import GENERATED_IMAGE_DIR
 from utility import webqtlUtil                # Random number for the image
 
 import base64
@@ -127,8 +127,8 @@ class WGCNA(object):
 
         # The iconic WCGNA plot of the modules in the hanging tree
         self.results['imgurl'] = webqtlUtil.genRandStr("WGCNAoutput_") + ".png"
-        self.results['imgloc'] = webqtlConfig.TMPDIR + self.results['imgurl']
-        r_png(self.results['imgloc'], width=1000, height=600)
+        self.results['imgloc'] = GENERATED_IMAGE_DIR + self.results['imgurl']
+        r_png(self.results['imgloc'], width=1000, height=600, type='cairo-png')
         mergedColors = self.r_labels2colors(network[1])
         self.r_plotDendroAndColors(network[5][0], mergedColors, "Module colors", dendroLabels = False, hang = 0.03, addGuide = True, guideHang = 0.05)
         r_dev_off()