Example #1
0
	def scatter_plot(self, gene_id_list, output_fname='/tmp/scatter_plot.ps'):
		"""
		02-15-06
			1st gene is regarded as X, all others genes are treated as Y
		"""
		vector_list = []
		#gene_id_list may contain some inexistent genes
		real_gene_id_list = []
		for gene_id in gene_id_list:
			if gene_id in self.gene_id2expr_array:
				real_gene_id_list.append(gene_id)
				vector_list.append(self.gene_id2expr_array[gene_id])	
			else:
				sys.stderr.write("%s doesn't appear in the dataset\n"%(gene_id))
		
		if len(real_gene_id_list)>0:
		
			r.postscript("%s"%output_fname)
			axis_range = self.get_min_max(vector_list)
			no_of_curves = 1	#counting starts from 1st gene itself.
			
			no_of_curves += 1
			r.plot(vector_list[0], vector_list[1], xlab='value of %s'%real_gene_id_list[0], xlim=axis_range, ylim=axis_range, \
				ylab='other genes values', col=no_of_curves)
			for i in range(2, len(vector_list)):
				no_of_curves += 1
				r.points(vector_list[0], vector_list[i], col=no_of_curves)
			r.legend(axis_range[1], axis_range[1], gene_id_list, col=range(1, no_of_curves+1), lty=1, xjust=1)
			r.dev_off()
			return output_fname
		else:
			return None
Example #2
0
	def plot(self, vector_list, gene_id_list):
		self.no_of_curves = 0
		x_range = (1, len(vector_list[0]))
		y_range = self.get_min_max(vector_list)
		r.postscript("%s"%self.plot_file)
		for vector in vector_list:
			(x_list, y_list) = self.xy_list_return(vector)
			self._plot(x_list, y_list, x_range, y_range)
		
		r.legend(x_range[1], y_range[1], gene_id_list, col=range(1, self.no_of_curves+1), lty=1, pch='*', xjust=1)
		r.dev_off()
Example #3
0
def create_p_value_boxplot_eps(best_p_values, filename):
    from rpy import r
    r.postscript(filename, horizontal=False, height=4.5, width=6, pointsize=10)
    try:
        keys = best_p_values.keys()
        keys.sort()
        r.boxplot(
            map(best_p_values.get, keys), 
            names=map(str, keys),
            xlab="sample size", ylab="p-score")
    finally:
        r.dev_off()
Example #4
0
def create_p_value_boxplot_eps(best_p_values, filename):
    from rpy import r
    r.postscript(filename, horizontal=False, height=4.5, width=6, pointsize=10)
    try:
        keys = best_p_values.keys()
        keys.sort()
        r.boxplot(map(best_p_values.get, keys),
                  names=map(str, keys),
                  xlab="sample size",
                  ylab="p-score")
    finally:
        r.dev_off()
Example #5
0
    def __print_entropies(self, entropies):

        """
        This is for debugging purposes.
        """

        try:
            from rpy import r
        except:
            print "Could not import rpy module"
            return

        r.postscript(DEBUG_ENTROPIES_FILE)
        r.plot(entropies, type='b', xlab="Iterations", ylab="Entropy")
        r.dev_off()

        return
Example #6
0
from rpy import r
import os.path

# find out where the temp directory is
tempdir = r.tempdir()

# write its name into a file
f = open('tempdir','w')
f.write(tempdir)
f.close()

# put something there..
r.postscript(os.path.join(tempdir,"foo.ps"))
r.plot(1,1)
r.dev_off()