## Installation
You can install Papillon using Pypi:

`pip install papillon`

or Anaconda through conda-forge either installing only papillon:

`conda install -c conda-forge papillon`

or adding the the conda-forge channel and then installing it:

`conda config --add channels conda-forge`

`conda install papillon`

It should work with any IDE for data science (I tested jupyter-notebook and spyder).

## Before To start

After RNA-seq analysis with Galaxy,

download the 4 files generated by cuffdiff containing respectively:

_... transcript_FPKM_tracking..._

_... gene_FPKM_tracking ..._

_... gene_differential_expression..._

_... transcript_differential_expression..._

And put them in the same folder.

You can either use directly the files or change the names according to

cummeRbund in:

_... transcript_FPKM_tracking... = isoforms.fpkm_tracking_

_... gene_FPKM_tracking ... = gene.fpkm_tracking_

_... gene_differential_expression... = gene_exp.diff_

_... transcript_differential_expression... = isoform_exp.diff_

Functions
---------

**read\_files(files, path=None, drop\_comparison=None)**

_Accept cuffdiff/cummeRbund files as iterable ("transcript\_FPKM\_tracking", "gene\_FPKM\_tracking", "gene\_differential\_expression", "transcript\_differential\_expression") and return them to \_papillon\_builder() to create a Papillon\_db object._

 Parameters

 files - accept an iterable with the cuffdiff files names

 path - where to export Papillon generated files

 drop\_comparison - drop comparison (str) or list of comparisons to drop
from the cuffdiff table

 Example

pp.read\_files(["Files/gene\_exp.diff","Files/genes.fpkm\_tracking","Files/isoform\_exp.diff","Files/isoforms.fpkm\_tracking"])


***


**read\_folder(path, drop\_comparison=None)**

_Read the folder containing the cuffdiff/cummeRbund files, and return them to \_papillon\_builder() to create a Papillon\_db object._

 Parameters

 path - accept a str with the folder path, containing the cuffdiff files

 drop\_comparison - drop comparison (str) or list of comparisons to drop
from the cuffdiff table

 Example

 MyProject=pp.read\_folder("MyFolder/Test\_files")

***

**read\_db(path, drop\_comparison=None)**

_Deprecated. Use read\_folder() instead._


***


Classes
-------

### class Papillon\_db(builtins.object)

 _Create a Papillon\_db object using read\_folder() or read\_files() and_
_\_papillon\_builder_

#### Methods defined here:

**\_\_init\_\_(self, path, samples, comparisons, genes\_detected,**
**isoforms\_detected)**

_self.path - files path_

_self.samples - samples found_

_self.comparisons - comparisons found_

_self.genes\_detected - dataframe of genes detected_

_self.isoforms\_detected - dataframe of isoforms detected_

**\_\_str\_\_(self)**

_Return str(self)._

***

**change\_order(self, new\_order)**

_Change the samples order_

 Parameters

 new\_order: list of samples order

 Example

 MyProject.change\_order(["Sample 4","Sample 3","Sample 2","Sample 1"])


***


**drop\_comparison(self, comparison)**

_Drop Comparison (str) or list of comparisons_

 Parameters

 comparison: comparison (str) or list of comparisons

 Example

 MyProject.drop\_comparison(specific\_comparison)

***

**get\_gene(self, genelist=None, comparison='all', comparison\_sign=None,**
**fold\_ind=None, fold\_sign='>')**

_This method select genes per name or conditions. It return a_
_Papillon\_list object_

 Parameters

genelist - accept string (1 gene name), list of gene names or file with a list of gene names

comparison - To select genes higher/lower in one condition compared to another. Accept either "all" to pass all the comparisons, or accept only 1 comparison as str (already present in the data)

comparison\_sign - usable in combination with comparison, accept either ">" or "<"

fold\_ind - fold induction (log2) higher/lower then number

fold\_sign - usable in combination with fold\_ind, accept either ">" or "<"

 Example

Selection=MyProject.get\_gene(["CD44","CCL15"], comparison="Sample 1\_vs\_Sample 2", comparison\_sign="<", fold\_ind=1, fold\_sign="<")

***

**get\_isoform(self, genelist=None, comparison='all', comparison\_sign=None, fold\_ind=None, fold\_sign='>')**

_This function select isoforms. It creates a Papillon object_

 Parameters

genelist - accept string (1 gene name), list of gene names or file with
a list of gene names

comparison - To select genes higher/lower in one condition compared to
another. Accept either "all" to pass all the comparisons, or accept only
1 comparison as str (already present in the data)

 comparison\_sign - usable in combination with comparison, accept either
">" or "<"

 fold\_ind - fold induction (log2) higher/lower then number

 fold\_sign - usable in combination with fold\_ind, accept either ">" or
"<"

 Example

 Selection=MyProject.get\_isoform(["IL6","CCL15","IL17RC"],
comparison="Sample 2\_vs\_Sample 4", comparison\_sign="<")

***

**search(self, word, where, how='table', export=False)**

 _search among genes/isoforms names in detected and significant_

 Parameters

 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

 export - True/False

 Example

 search\_result=MyProject.search(word="IL6",where="genes\_significant",
how="table")

***

### class Papillon\_list(builtins.object)

_Class containing a selected list of genes, with data associated,_
_generated by Papillon\_db.get\_gene() or Papillon\_db.get\_isoform()_
_methods_

_Is possible add the content of two or more Papillon\_list objects._

_Example:_

_P\_list3 = P\_list1+P\_list2_

_P\_list4=sum([PL1, PL2, PL3])_

####  Methods defined here:

\_\_add\_\_(self, other)

\_\_init\_\_(self, df, what, comparisons, path, samples,
comparison='all', comparison\_sign=None, fold\_ind=None, fold\_sign='>',
p=0.05)

 Initialize self. See help(type(self)) for accurate signature.

\_\_radd\_\_(self, other)

\_\_str\_\_(self)

 Return str(self).

***

**compare(self, other)**

_Compare two Papillon\_list objects_

 Parameters

 other: another Papillon\_list object

 Example

 Selection1.compare(Selection2)

***

**export(self)**

_Export the selected genes/isoforms as excel file._

 Example

 Selection.export()

***

**heatmap(self, z\_score=False, col\_cluster=False, method='complete',**
**cmap='seismic', export=False, \*\*options)**

_Generate heatmap using selected genes/isoforms_

 Parameters

 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.

 Example

 Selection.heatmap(z\_score=True,export=True)

***

**lineplot(self, title='', legend=True, z\_score=False, export=False,**
**size=10, ci=None, \*\*option)**

_LinePlot selected genes expression levels. Max number of genes 200_

 Parameters

 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

 size - change the size of the plot

 \*\*options - all the options accepted by seaborn.factorplot

 Example

 Selection.lineplot(export=True,z\_score=True)

***

**onlyFPKM(self, return\_as, remove\_FPKM\_name=False)**

 _Take a Papillon\_list object and return only FPKM columns._

 Parameters

 return as:

 "df" - pandas DataFrame

 "array" - numpy array

 "gene name" - pandas DataFrame containing gene names

 remove\_FPKM\_name: True/False

 Example

 df=Selection.onlyFPKM("df")

***

**plot(\*\*parameter)**

_Deprecated. Use self.lineplot() instead_

***

**search(self, string)**

_Search a string in the Papillon\_list_

 Parameters

 string - accept a str to search among the gene names

 Example

 search\_results=Selection.search("IL")

***

**select(self, genelist)**

_Create another Papillon\_list object_

 Parameters

 genelist: accept string (1 gene name), list of gene names or file

 with a list of gene names

 Example

 Selection2=Selection1.select(["IL6","CCL15"])

***

**show(self)**

_Show genes/isoforms as Dataframe_

 Example

 Selection.show()

