papillon
index
/home/lab/Documents/GitHub/Papillon/papillon.py

A python version of CummeRbund
to read and plot Galaxy/cuffdiff RNA-seq data

 
Modules
       
os
pandas
seaborn
warnings

 
Classes
       
builtins.object
Papillon_db
Papillon

 
class Papillon(Papillon_db)
    Select and plot genes/isoforms from a Papillon_db
 
self.selected - gene/isoform selected
self.type_selected - either gene or isoform according with selection type
 
 
Method resolution order:
Papillon
Papillon_db
builtins.object

Methods defined here:
get_gene(self, genelist=None, comparison=None, sign=None, export=False)
This function select genes. It creates
 
self.selected
self.type_selected="gene".
 
genelist - accept string (gene name), list of gene names or file
           with a list of gene names
comparison - accept only 1 comparison as str (already present in
             the data)
sign - usable in combination with comparison, accept either ">" or
       "<"
export - True/False whether want or not export the dataframe of
         selected genes
get_isoform(self, genelist=None, comparison=None, sign=None, export=False, show_dup=False)
This function select isoforms. It creates
self.selected
self.type_selected="isoform"
 
genelist - accept string (gene name), list of gene names or file
           with a list of gene names
comparison - accept only 1 comparison as str (already present in
             the data)
sign - usable in combination with comparison, accept either ">" or
       "<"
export - True/False whether want or not export the dataframe of
         selected genes
show_dup - True/False whether want or not highlight duplicated
           isoforms for the same gene
heatmap(self, z_score=True, col_cluster=False, method='complete', cmap='seismic', export=False, **options)
Generate heatmap using selected genes/isoforms
z_score - True/False whether want or not apply z-score normalization
col_cluster - True/False whether want or not cluster the samples
method - clustering algorithm - default is complete-linkage
cmap - map color
export - True/False whether want or not export the dataframe of
         selected genes
**options - all the options accepted by seaborn.clustermap
default metric is euclidean.
lineplot(self, title='', legend=True, z_score=False, export=False, df=None, size=10, ci=None, **option)
LinePlot selected genes expression levels. Max number of genes 200
 
title - accept a str as title of the plot
legend - True/False show the legend
z_score - True/False calculate the z-score normalization
export - True/False whether or not export the image
df - accept an exernal dataframe, different from self.selected
**options - all the options accepted by seaborn.factorplot
onlyFPKM(self, return_as, **option)
It uses self.selected or an extra_df and Return only FPKM columns.
 
return as:
    "df" - pandas DataFrame
    "array" - numpy array
    "gene name" - pandas DataFrame containing gene names
 
**option accept extra_df as exernal Pandas df
plot(self, title='', legend=True, z_score=False, export=False, df=None, size=10, ci=None, **option)
Use self.lineplot() instead. self.plot() will not work in the future
search(self, word, where, how='table', export=False)
search among genes/isoforms names in detected and significant
 
word - accept a str to search among the gene names
where - accept:
    "genes_detected"
    "genes_significant"
    "isoforms_detected"
    "isoforms_significant"
 
how - accept:
    "table" return the dataframe with the genes found
    "list" return a list of names, no duplicates
    "selected" put the genes found among the differential expressed
               genes in self.selected (to plot),
               working only with where="significant"

Methods inherited from Papillon_db:
__init__(self, path, samples, comparisons, genes_detected, genes_significant, isoforms_detected, isoform_significant)
Initialize self.  See help(type(self)) for accurate signature.
__str__(self)
Return str(self).
change_order(self, new_order)
Change the samples order
 
new_order: list of samples order
dropComparison(self, comparison)
Drop Comparison (str) or list of comparisons and re-calculate
df_significant
 
comparison: comparison (str) or list of comparisons
selected_exist(self, remove=False)
Check if self.selected exists
 
remove: True/False. If True remove self.selected and self.type_selected

Data descriptors inherited from Papillon_db:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Papillon_db(builtins.object)
    Make a Papillon_db object and permit to change some values
 
self.path - files path
self.samples - samples found
self.comparison - comparisons found
self.genes_detect - dataframe of genes detected
self.genes_significant - dataframe of genes significant
self.isoforms_detect - dataframe of isoforms detected
self.isoforms_significant - dataframe of isoforms significant
expressed
redefine __str__
 
  Methods defined here:
__init__(self, path, samples, comparisons, genes_detected, genes_significant, isoforms_detected, isoform_significant)
Initialize self.  See help(type(self)) for accurate signature.
__str__(self)
Return str(self).
change_order(self, new_order)
Change the samples order
 
new_order: list of samples order
dropComparison(self, comparison)
Drop Comparison (str) or list of comparisons and re-calculate
df_significant
 
comparison: comparison (str) or list of comparisons
selected_exist(self, remove=False)
Check if self.selected exists
 
remove: True/False. If True remove self.selected and self.type_selected

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
read_db(path, drop_comparison=None)
Use read_folder() instead. read_db() will not work in the future
read_files(files, path=None, drop_comparison=None)
Accept cuffdiff/cummeRbund files as iterable, and return
them to _papillon_builder().
 
files - accept an iterable with the cuffdiff files
path - where export Papillon generated files
drop_comparison - drop comparison (str) or list of comparisons and
re-calculate significant genes/isoforms
read_folder(path, drop_comparison=None)
Read the folder containing the cuffdiff/cummeRbund files, and return
them to _papillon_builder().
 
path - accept a str with the folder path, containing the cuffdiff files
drop_comparison - drop comparison (str) or list of comparisons and
re-calculate significant genes/isoforms