Skip to content
Permalink
Browse files

example with relative file

  • Loading branch information
tmoerman committed Jun 10, 2018
1 parent a55f682 commit 16d805c515d6530ce9be824db99891d304c755e8
Showing with 69 additions and 3 deletions.
  1. +39 −3 docs/examples.rst
  2. +2 −0 docs/rebuild.sh
  3. +28 −0 resources/dream5/net1/run_grnboost2.py
@@ -1,4 +1,5 @@

.. _`python script`: https://github.com/tmoerman/arboreto/blob/master/resources/dream5/net1/run_grnboost2.py
.. _`Example 01 - GRNBoost2 local`: https://nbviewer.jupyter.org/github/tmoerman/arboreto/blob/master/notebooks/examples/ex_01_grnboost2_local.ipynb
.. _`Example 02 - GRNBoost2 with custom Dask Client`: https://nbviewer.jupyter.org/github/tmoerman/arboreto/blob/master/notebooks/examples/ex_02_grnboost2_custom_client.ipynb
.. _`Example 03 - GRNBoost2 with transposed input file`: https://nbviewer.jupyter.org/github/tmoerman/arboreto/blob/master/notebooks/examples/ex_03_grnboost2_transposed_input_file.ipynb
@@ -9,10 +10,45 @@
Examples
========

Python scripts
--------------
Python script
-------------

* Example `python script`_ running GRNBoost2 on files located in the same folder.

Run as a classic python script: ``python run_grnboost2`` from the ``<arboreto repo>/resources/dream5/net1`` folder.

.. code-block:: python
:caption: *<arboreto repo>/resources/dream5/net1/run_grnboost2.py*
import pandas as pd
from distributed import Client, LocalCluster
from arboreto.utils import load_tf_names
from arboreto.algo import grnboost2
if __name__ == '__main__':
in_file = 'net1_expression_data.tsv'
tf_file = 'net1_transcription_factors.tsv'
out_file = 'net1_grn_output.tsv'
# ex_matrix is a DataFrame with gene names as column names
ex_matrix = pd.read_csv(in_file, sep='\t')
# tf_names is read using a utility function included in Arboreto
tf_names = load_tf_names(tf_file)
# instantiate a custom Dask distributed Client
client = Client(LocalCluster())
# compute the GRN
network = grnboost2(expression_data=ex_matrix,
tf_names=tf_names,
client_or_address=client)
# write the GRN to file
network.to_csv(out_file, sep='\t', index=False, header=False)
* TODO
Jupyter notebooks
-----------------
@@ -0,0 +1,2 @@
make html
# firefox _build/html/index.html
@@ -0,0 +1,28 @@
import pandas as pd

from distributed import Client, LocalCluster
from arboreto.utils import load_tf_names
from arboreto.algo import grnboost2

if __name__ == '__main__':

in_file = 'net1_expression_data.tsv'
tf_file = 'net1_transcription_factors.tsv'
out_file = 'net1_grn_output.tsv'

# ex_matrix is a DataFrame with gene names as column names
ex_matrix = pd.read_csv(in_file, sep='\t')

# tf_names is read using a utility function included in Arboreto
tf_names = load_tf_names(tf_file)

# instantiate a custom Dask distributed Client
client = Client(LocalCluster())

# compute the GRN
network = grnboost2(expression_data=ex_matrix,
tf_names=tf_names,
client_or_address=client)

# write the GRN to file
network.to_csv(out_file, sep='\t', index=False, header=False)

0 comments on commit 16d805c

Please sign in to comment.
You can’t perform that action at this time.