CAnBioNet / TkNA

9 stars 1 forks source link

TkNA

Usage

NB: If you have not already set up a conda environment and cloned the repo, please complete the steps in Creating a conda environment.txt before running the following commands.

Note that script paths are given relative to the top-level repository directory.

1. Normalize data

Data should be normalized prior to running TkNA. Examples of normalization methods can be found in the TkNA manuscript.

2. Format data and set statistical thresholds

Data must be formatted in the format specified in the TkNA manuscript.

3. Import the data and metadata for the run

Usage

python ./reconstruction/intake_data.py --data-dir <data directory> --out-file <output file>

Example command

python reconstruction/intake_data.py --data-dir ./project_folder/input/ --out-file ./project_folder/output/all_data_and_metadata.zip

Inputs

Outputs

A single .zip file containing most information required for the next step

4. Run the correlations and comparisons, supplying the config file, which tells code which thresholds to apply. For larger datasets, use more cores.

Usage

python ./reconstruction/run.py --data-source <file_name> --config-file <config file> --out-file <zip file>

Example command

python ./reconstruction/run.py --data-source ./project_folder/output/all_data_and_metadata.zip --config-file ./project_folder/input/config.json --out-file ./project_folder/output/network_output.zip

Inputs

Outputs

5. Convert the output files to csv

Usage

python ./reconstruction/to_csv.py --data-file <zip file> --config-file <config file> --out-dir <output directory>

Example command

python ./reconstruction/to_csv.py --data-file ./project_folder/output/network_output.zip --config-file ./project_folder/input/config.json --out-dir ./project_folder/output/network_output

Inputs

Outputs

6. Assess the quality of the reconstructed network

Usage

python ./analysis/assess_network.py --file <network file> --out-dir <directory>

Example command

python ./analysis/assess_network.py --file ./project_folder/output/network_output/correlations_bw_signif_measurables.csv --out-dir ./project_folder/output/network_output/

Inputs

Outputs

7. Identify clusters of nodes (OPTIONAL)...

...using Infomap

Usage

python ./analysis/infomap_assignment.py --network <file> --network-format <format> --map <file.csv> --out-dir <directory>

Example command

python ./analysis/infomap_assignment.py --network ./project_folder/output/network_output/network_output_comp.csv --network-format csv --map ./project_folder/input/type_map.csv --out-dir ./project_folder/output/network_output/

Inputs

Output

...using the Louvain method

Usage

python ./analysis/louvain_partition.py --network <file> --network-format <format> --map <file.csv> --out-dir <directory>    

Example command

python ./analysis/louvain_partition.py --network ./project_folder/output/network_output/network_output_comp.csv --network-format csv --map ./project_folder/input/type_map.csv --out-dir ./project_folder/output/network_output/

Inputs and arguments

Output

8. Perform functional enrichment analysis for groups of nodes (OPTIONAL)

Functional enrichment of the resulting partitions can be performed using the methods mentioned in the TkNA manuscript.

9. Find the distance (shortest path) between two pathways (OPTIONAL)

Pathways closer to one another potentially interact more than those that are further away.

Usage

python ./analysis/find_all_shortest_paths_bw_subnets.py --network <file.pickle> --network-format <format> --map <map.csv> --node-groups <group1> <group2> --out-dir <directory> 

Example command

python ./analysis/find_all_shortest_paths_bw_subnets.py --network ./project_folder/output/network_output/network_output_comp.csv --network-format csv --map ./project_folder/input/type_map.csv --node-groups microbe pheno --out-dir ./project_folder/output/network_output/

Inputs and arguments

Output

10. Calculate network topology parameters (e.g. degree, BiBC, etc.)

Usage

python ./analysis/calc_network_properties.py --network <file.csv> --bibc --bibc-groups <choice> --bibc-calc-type <choice> --map <file.csv> --node-groups <group 1> <group 2> --out-dir <directory>

Example command:

python ./analysis/calc_network_properties.py --network ./project_folder/output/network_output/network_output_comp.csv --bibc --bibc-groups node_types --bibc-calc-type rbc --map ./project_folder/input/type_map.csv --node-groups microbe pheno --out-dir ./project_folder/output/network_output/

Inputs and arguments

Output

11. Create random networks

Usage

python ./random_networks/create_random_networks.py --template-network <file.pickle> --networks-file <file.zip>  

Example command

python ./random_networks/create_random_networks.py --template-network ./project_folder/output/network_output/network.pickle --networks-file ./project_folder/output/network_output/all_random_nws.zip 

Inputs

Output

12. Analyze random networks

Usage

python ./random_networks/compute_network_stats.py --networks-file <file.zip> --bibc-groups <choice> --bibc-calc-type <choice> --stats-file <file.zip> --node-map <file.csv> --node-groups <group1> <group2>

Example command

python ./random_networks/compute_network_stats.py --networks-file ./project_folder/output/network_output/all_random_nws.zip --bibc-groups node_types --bibc-calc-type rbc --stats-file ./project_folder/output/network_output/random_network_analysis.zip --node-map ./project_folder/input/type_map.csv --node-groups microbe pheno

Inputs

Outputs

13. Condense random network outputs into one file

Usage

python ./random_networks/synthesize_network_stats.py --network-stats-file <file.zip> --synthesized-stats-file <file.csv> 

Example command

python ./random_networks/synthesize_network_stats.py --network-stats-file ./project_folder/output/network_output/random_network_analysis.zip --synthesized-stats-file ./project_folder/output/network_output/random_networks_synthesized.csv

Inputs

Outputs

14. Create dot plots for node properties

Usage

python ./visualization/dot_plots.py --pickle <file.pickle> --node-props  <file.txt> --network-file <file.csv> --propx BiBC --propy Node_degrees --top-num <integer> --top-num-per-type <inte-ger> --plot-dir <directory> --file-dir <directory>

Example command

python ./visualization/dot_plots.py --pickle ./project_folder/output/network_output/network.pickle --node-props ./project_folder/output/network_output/node_properties.txt --network-file ./project_folder/output/network_output/network_output_comp.csv --propx BiBC_microbe_pheno --propy Node_degrees --top-num 5 --top-num-per-type 3   --plot-dir ./project_folder/output/network_output/plots/ --file-dir ./project_folder/output/network_output/

Inputs

Default outputs

15. Create abundance plots

Usage

python ./visualization/plot_abundance.py --pickle <file.pickle> --abund-data <list of files> --metadata <list of files> --x-axis <choice> --group-names <list of names> --group-colors <list of color names> 

Example command

python ./visualization/plot_abundance.py --pickle ./project_folder/output/network_output/inputs_for_downstream_plots.pickle --abund-data ./project_folder/input/Experiment1.csv ./project_folder/input/Experiment2.csv --metadata ./project_folder/input/Experiment1_group_map.csv ./project_folder/input/Experiment2_group_map.csv --x-axis Experiment --group-names ileum8wkHFHS ileum8wkNCD stool4wkHFHS stool8wkHFHS --group-colors orange blue red green

Inputs

Outputs

16. Plot density/contour plot of distributions of top nodes in a random network and overlay the nodes from the actual reconstructed network

Usage

python ./visualization/plot_density.py --rand-net <file.csv> --pickle <file.pickle> --bibc-name <name>

Example command

python ./visualization/plot_density.py --rand-net ./project_folder/output/network_output/random_networks_synthesized.csv --pickle ./project_folder/output/network_output/inputs_for_downstream_plots.pickle --bibc-name BiBC_microbe_pheno

Inputs

Default outputs