-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
147 changed files
with
8,288 additions
and
3,781 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import argparse | ||
import pandas as pd | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
# parse command-line arguments | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--emx", required=True, help="expression matrix file", dest="EMX") | ||
parser.add_argument("--cmx", required=True, help="correlation matrix file", dest="CMX") | ||
parser.add_argument("-o", "--output", required=True, help="output net file", dest="OUTPUT") | ||
parser.add_argument("--mincorr", type=float, default=0, help="minimum absolute correlation threshold", dest="MINCORR") | ||
parser.add_argument("--maxcorr", type=float, default=1, help="maximum absolute correlation threshold", dest="MAXCORR") | ||
|
||
args = parser.parse_args() | ||
|
||
# load data | ||
emx = pd.read_table(args.EMX) | ||
cmx = pd.read_table(args.CMX, header=None, names=[ | ||
"x", | ||
"y", | ||
"Cluster", | ||
"Num_Clusters", | ||
"Cluster_Samples", | ||
"Missing_Samples", | ||
"Cluster_Outliers", | ||
"Pair_Outliers", | ||
"Too_Low", | ||
"sc", | ||
"Samples" | ||
]) | ||
|
||
# extract correlations within thresholds | ||
cmx = cmx[(args.MINCORR <= abs(cmx["sc"])) & (abs(cmx["sc"]) <= args.MAXCORR)] | ||
|
||
# insert additional columns used in netlist format | ||
cmx.insert(len(cmx.columns), "Source", [emx.index[x] for x in cmx["x"]]) | ||
cmx.insert(len(cmx.columns), "Target", [emx.index[y] for y in cmx["y"]]) | ||
cmx.insert(len(cmx.columns), "Interaction", ["co" for idx in cmx.index]) | ||
|
||
# reorder columns to netlist format | ||
cmx = cmx[[ | ||
"Source", | ||
"Target", | ||
"sc", | ||
"Interaction", | ||
"Cluster", | ||
"Num_Clusters", | ||
"Cluster_Samples", | ||
"Missing_Samples", | ||
"Cluster_Outliers", | ||
"Pair_Outliers", | ||
"Too_Low", | ||
"Samples" | ||
]] | ||
|
||
# save output data | ||
cmx.to_csv(args.OUTPUT, sep="\t", index=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
|
||
# parse command-line arguments | ||
if [[ $# != 1 ]]; then | ||
echo "usage: $0 <infile>" | ||
exit -1 | ||
fi | ||
|
||
# define analytic flags | ||
DO_SIMILARITY=1 | ||
DO_THRESHOLD=1 | ||
DO_EXTRACT=1 | ||
|
||
# define input/output files | ||
DATA="data" | ||
EMX_FILE="$1" | ||
CMX_FILE="$DATA/$(basename $EMX_FILE .txt)-cmx-py.txt" | ||
NET_FILE="$DATA/$(basename $EMX_FILE .txt)-net-py.txt" | ||
|
||
# similarity | ||
if [[ $DO_SIMILARITY = 1 ]]; then | ||
CLUSMETHOD="gmm" | ||
CORRMETHOD="pearson" | ||
MINEXPR="-inf" | ||
MINCLUS=1 | ||
MAXCLUS=5 | ||
CRITERION="bic" | ||
PREOUT="--preout" | ||
POSTOUT="--postout" | ||
MINCORR=0 | ||
MAXCORR=1 | ||
|
||
python scripts/similarity.py \ | ||
-i $EMX_FILE \ | ||
-o $CMX_FILE \ | ||
--clusmethod $CLUSMETHOD \ | ||
--corrmethod $CORRMETHOD \ | ||
--minexpr=$MINEXPR \ | ||
--minclus $MINCLUS --maxclus $MAXCLUS \ | ||
--crit $CRITERION \ | ||
$PREOUT $POSTOUT \ | ||
--mincorr $MINCORR --maxcorr $MAXCORR | ||
fi | ||
|
||
# threshold | ||
if [[ $DO_THRESHOLD = 1 ]]; then | ||
NUM_GENES=$(expr $(cat $EMX_FILE | wc -l) - 1) | ||
METHOD="rmt" | ||
TSTART=0.99 | ||
TSTEP=0.001 | ||
TSTOP=0.50 | ||
|
||
python scripts/threshold.py \ | ||
-i $CMX_FILE \ | ||
--genes $NUM_GENES \ | ||
--method $METHOD \ | ||
--tstart $TSTART \ | ||
--tstep $TSTEP \ | ||
--tstop $TSTOP | ||
fi | ||
|
||
# extract | ||
if [[ $DO_EXTRACT = 1 ]]; then | ||
MINCORR=0 | ||
MAXCORR=1 | ||
|
||
python scripts/extract.py \ | ||
--emx $EMX_FILE \ | ||
--cmx $CMX_FILE \ | ||
--output $NET_FILE \ | ||
--mincorr $MINCORR \ | ||
--maxcorr $MAXCORR | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/bin/bash | ||
|
||
# parse command-line arguments | ||
if [[ $# != 1 ]]; then | ||
echo "usage: $0 <infile>" | ||
exit -1 | ||
fi | ||
|
||
GPU=1 | ||
|
||
# define analytic flags | ||
DO_IMPORT_EMX=1 | ||
DO_SIMILARITY=1 | ||
DO_EXPORT_CMX=1 | ||
DO_THRESHOLD=1 | ||
DO_EXTRACT=1 | ||
|
||
# define input/output files | ||
INFILE="$1" | ||
DATA="data" | ||
EMX_FILE="$DATA/$(basename $INFILE .txt).emx" | ||
CCM_FILE="$DATA/$(basename $EMX_FILE .emx).ccm" | ||
CMX_FILE="$DATA/$(basename $EMX_FILE .emx).cmx" | ||
LOGS="logs" | ||
RMT_FILE="$LOGS/$(basename $CMX_FILE .cmx).txt" | ||
|
||
# apply settings | ||
if [[ $GPU == 1 ]]; then | ||
kinc settings set opencl 0:0 | ||
kinc settings set threads 4 | ||
kinc settings set logging off | ||
|
||
NP=1 | ||
else | ||
kinc settings set opencl none | ||
kinc settings set logging off | ||
|
||
NP=$(nproc) | ||
fi | ||
|
||
# import emx | ||
if [[ $DO_IMPORT_EMX = 1 ]]; then | ||
kinc run import-emx \ | ||
--input $INFILE \ | ||
--output $EMX_FILE \ | ||
--nan NA | ||
fi | ||
|
||
# similarity | ||
if [[ $DO_SIMILARITY = 1 ]]; then | ||
CLUSMETHOD="gmm" | ||
CORRMETHOD="pearson" | ||
MINEXPR="-inf" | ||
MINCLUS=1 | ||
MAXCLUS=5 | ||
CRITERION="BIC" | ||
PREOUT="--preout" | ||
POSTOUT="--postout" | ||
MINCORR=0.5 | ||
MAXCORR=1 | ||
|
||
mpirun -np $NP kinc run similarity \ | ||
--input $EMX_FILE \ | ||
--ccm $CCM_FILE \ | ||
--cmx $CMX_FILE \ | ||
--clusmethod $CLUSMETHOD \ | ||
--corrmethod $CORRMETHOD \ | ||
--minexpr $MINEXPR \ | ||
--minclus $MINCLUS --maxclus $MAXCLUS \ | ||
--crit $CRITERION \ | ||
$PREOUT $POSTOUT \ | ||
--mincorr $MINCORR --maxcorr $MAXCORR | ||
fi | ||
|
||
# export cmx | ||
if [[ $DO_EXPORT_CMX = 1 ]]; then | ||
OUTFILE="$DATA/$(basename $CMX_FILE .cmx)-cmx.txt" | ||
|
||
kinc run export-cmx \ | ||
--emx $EMX_FILE \ | ||
--ccm $CCM_FILE \ | ||
--cmx $CMX_FILE \ | ||
--output $OUTFILE | ||
fi | ||
|
||
# threshold | ||
if [[ $DO_THRESHOLD = 1 ]]; then | ||
mkdir -p $LOGS | ||
|
||
kinc run rmt \ | ||
--input $CMX_FILE \ | ||
--log $RMT_FILE | ||
fi | ||
|
||
# extract | ||
if [[ $DO_EXTRACT = 1 ]]; then | ||
NET_FILE="$DATA/$(basename $EMX_FILE .emx)-net.txt" | ||
MINCORR=0 | ||
MAXCORR=1 | ||
|
||
kinc run extract \ | ||
--emx $EMX_FILE \ | ||
--ccm $CCM_FILE \ | ||
--cmx $CMX_FILE \ | ||
--output $NET_FILE \ | ||
--mincorr $MINCORR \ | ||
--maxcorr $MAXCORR | ||
fi |
Oops, something went wrong.