Skip to content

Commit

Permalink
added docs for plot_network
Browse files Browse the repository at this point in the history
  • Loading branch information
proost committed Mar 13, 2017
1 parent 4e5bf05 commit 473f027
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
11 changes: 10 additions & 1 deletion docs/helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,20 @@ derived from the *Sorghum bicolor* case study, in included in the repository.
### plot_network

Script that plots the co-expression neighborhood for a specific gene. A PCC cutoff of 0.7 is included by default,
but users can override this setting using the --cutoff parameter.
but users can override this setting using the --cutoff parameter. Matplotlib and networkx are required for this
script.

# To draw plot to screen using a PCC cutoff of >= 0.8
python3 plot_network.py <PCC_TABLE> <GENE_ID> --cutoff 0.8

# Save as png
python3 plot_network.py <PCC_TABLE> <GENE_ID> --cutoff 0.8 --png output.png

# Set png dpi (for publication)
python3 plot_network.py <PCC_TABLE> <GENE_ID> --cutoff 0.8 --png output.png --dpi 900



![matrix example](images/plot_network.png "Example of plotted network")

### matrix_heatmap.py
Expand Down
Binary file added docs/images/plot_network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions helper/plot_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
DEBUG = True


def plot_network(filename, gene, cutoff=0.7):
def plot_network(filename, gene, cutoff=0.7, png=None, dpi=300):
"""
Function to load a co-expression network from LSTrAP and plot the neighborhood for one gene.
Expand Down Expand Up @@ -89,7 +89,11 @@ def plot_network(filename, gene, cutoff=0.7):
nx.draw_networkx_labels(graph, pos, {k: k for k in valid_genes}, font_size=16, alpha=0.5)

plt.axis('off')
plt.show()
if png is None:
plt.show()
else:
plt.savefig(png, format='png', dpi=dpi)
print("Wrote output to %s" % png)


if __name__ == "__main__":
Expand All @@ -100,10 +104,13 @@ def plot_network(filename, gene, cutoff=0.7):

parser.add_argument('--cutoff', help='PCC cutoff to use (default = 0.7)', default=0.7, type=float)

parser.add_argument('--png', help='save output as png file (default: None, don\'t write png to file)', default=None)
parser.add_argument('--dpi', help='dpi for the output (default = 300)', default=300, type=float)

parser.set_defaults(show_labels=True)

# Parse arguments and start script
args = parser.parse_args()

plot_network(args.filename, args.gene, cutoff=args.cutoff)
plot_network(args.filename, args.gene, cutoff=args.cutoff, png=args.png, dpi=args.dpi)

0 comments on commit 473f027

Please sign in to comment.