Skip to content

Commit 5c48649

Browse files
update to v3.2.0
1 parent 177adfd commit 5c48649

31 files changed

+13954
-1974
lines changed

DreamDIA.py

Lines changed: 68 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,92 @@
1+
"""
2+
╔═════════════════════════════════════════════════════╗
3+
║ DreamDIA.py ║
4+
╠═════════════════════════════════════════════════════╣
5+
║ Description: DreamDIA user interfaces ║
6+
╠═════════════════════════════════════════════════════╣
7+
║ Author: Mingxuan Gao ║
8+
║ Contact: [email protected]
9+
╚═════════════════════════════════════════════════════╝
10+
"""
11+
112
import os
13+
214
import click
3-
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
15+
import tensorflow as tf
16+
417
from dream_score import dream_score
18+
from dream_prophet import dream_prophet
19+
from art import logo
20+
21+
# Set TensorFlow log level
22+
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
23+
#os.environ["CUDA_VISIBLE_DEVICES"] = "1"
24+
25+
# Configure TensorFlow logger to suppress warnings
26+
tf.get_logger().setLevel('ERROR')
27+
28+
# Configure CLI context settings
529
CONTEXT_SETTINGS = dict(help_option_names = ['-h', '--help'], max_content_width = 120)
30+
631
def print_version(ctx, param, value):
732
if not value or ctx.resilient_parsing:
833
return
9-
click.echo('DreamDIA-XMBD Version 2.0.3')
34+
click.echo('DreamDIA Version 3.2.0')
35+
click.echo(logo)
1036
ctx.exit()
37+
1138
@click.group(context_settings = CONTEXT_SETTINGS)
1239
@click.option('--version', is_flag = True, callback = print_version, expose_value = False, is_eager = True, help = "Print version and exit.")
1340
def dreamdia():
41+
"""DreamDIA: A DIA data analysis software suite. """
1442
pass
43+
1544
@dreamdia.command(context_settings = CONTEXT_SETTINGS)
1645
@click.option("--file_dir", required = True, type = click.Path(exists = True), help = "Directory that contains only DIA data files. Centroided .mzXML, .mzML or .raw files from Thermo Fisher equipments are supported. (For Linux systems, `mono` tool has to be installed for the supporting of .raw files. https://www.mono-project.com/download/stable/#download-lin)")
1746
@click.option("--lib", required = True, type = click.Path(exists = True), help = "File name of the spectral library. .tsv or .csv formats are supported.")
1847
@click.option("--out", required = True, type = click.Path(exists = False), help = "Directory for output files.")
19-
@click.option("--n_threads", default = 32, show_default = True, type = int, help = "Number of threads.")
20-
@click.option("--seed", default = 123, show_default = True, type = int, help = "Random seed for decoy generation.")
48+
@click.option("--n_threads", default = 16, show_default = True, type = int, help = "Number of threads.")
49+
@click.option("--seed", default = 123, show_default = True, type = int, help = "Random seed.")
2150
@click.option("--mz_unit", default = "Da", show_default = True, type = click.Choice(['Da', 'ppm']), help = "m/z unit for m/z range and tolerance settings.")
2251
@click.option("--mz_min", default = "99", show_default = True, type = int, help = "Minimum of m/z value.")
2352
@click.option("--mz_max", default = "1801", show_default = True, type = int, help = "Maximum of m/z value.")
2453
@click.option("--mz_tol_ms1", default = "0.01", show_default = True, type = float, help = "m/z tolerance for MS1.")
2554
@click.option("--mz_tol_ms2", default = "0.03", show_default = True, type = float, help = "m/z tolerance for MS2.")
26-
@click.option("--fdr_precursor", default = "0.01", show_default = True, type = float, help = "FDR of precursor level.")
27-
@click.option("--fdr_protein", default = "0.01", show_default = True, type = float, help = "FDR of protein level.")
28-
@click.option("--n_irt", default = "500", show_default = True, type = int, help = "Number of endogenous precursors for RT normalization.")
29-
@click.option("--top_k", default = "10", show_default = True, type = int, help = "Number of RSMs for each precursor to extract.")
30-
@click.option("--n_cycles", default = "300", show_default = True, type = int, help = "Number of RT cycles to search for RSMs for each precursor. Must be greater than (topk + model_cycles - 1).")
55+
@click.option("--n_irts", default = "4000", show_default = True, type = int, help = "Number of endogenous precursors for RT normalization. Minimum: 150.")
56+
@click.option("--irt_mode", default = "irt", show_default = True, type = click.Choice(['irt', 'rt']), help = "Whether the RT coordinates in the library are iRT values or RT values.")
57+
@click.option("--irt_score_cutoff", default = "0.99", show_default = True, type = float, help = "Cut-off Dream score for RT normalization.")
58+
@click.option("--irt_score_libcos_cutoff", default = "0.95", show_default = True, type = float, help = "Cut-off library cosine similarity score for RT normalization.")
59+
@click.option("--rt_norm_model", default = "nonlinear", show_default = True, type = click.Choice(['linear', 'nonlinear', 'calib']), help = "Use linear, non-linear or Calib-RT model for RT normalizaiton.")
60+
@click.option("--n_cycles", default = "300", show_default = True, type = int, help = "Number of RT cycles to search for RSMs for each precursor. Must be greater than 21.")
3161
@click.option("--n_frags_each_precursor", default = "3", show_default = True, type = int, help = "Number of fragment ions at least for each precursor.")
32-
@click.option("--do_not_output_library", is_flag = True, help = "Do not output the library with decoys generated by DreamDIA-XMBD. If this option is not activated, the library with decoys will be saved at the same directory of the input library.")
33-
@click.option("--model_cycles", default = "12", show_default = True, type = int, help = "(# Do not modify this argument unless customed deep representation models are used.) Number of RT cycles of the XICs.")
34-
@click.option("--n_lib_frags", default = "20", show_default = True, type = int, help = "(# Do not modify this argument unless customed deep representation models are used.) Number of XICs in 'library' part of the RSMs of the deep representation models.")
35-
@click.option("--n_self_frags", default = "50", show_default = True, type = int, help = "(# Do not modify this argument unless customed deep representation models are used.) Number of XICs in 'self' part of the RSMs of the deep representation models.")
36-
@click.option("--n_qt3_frags", default = "10", show_default = True, type = int, help = "(# Do not modify this argument unless customed deep representation models are used.) Number of XICs in 'qt3' part of the RSMs of the deep representation models.")
37-
@click.option("--n_ms1_frags", default = "10", show_default = True, type = int, help = "(# Do not modify this argument unless customed deep representation models are used.) Number of XICs in 'ms1' part of the RSMs of the deep representation models.")
38-
@click.option("--n_iso_frags", default = "20", show_default = True, type = int, help = "(# Do not modify this argument unless customed deep representation models are used.) Number of XICs in 'iso' part of the RSMs of the deep representation models.")
39-
@click.option("--n_light_frags", default = "20", show_default = True, type = int, help = "(# Do not modify this argument unless customed deep representation models are used.) Number of XICs in 'light' part of the RSMs of the deep representation models.")
40-
@click.option("--prophet_mode", default = "local", show_default = True, type = click.Choice(["local", "global"]), help = "Train a disciminant model on the RSMs of each sample respectively (local) or train a discriminant model on all the RSMs from all the samples (global).")
41-
@click.option("--disc_model", default = "xgboost", show_default = True, type = click.Choice(["xgboost", "rf"]), help = "Type of the discriminant model.")
42-
@click.option("--dream_indicators", is_flag = True, help = "[Deprecated] Activate Dream-Indicators to search better hyper-parameters for the discriminant model. If this option is not activated, the depths of the trees in the discriminant model will be heuristically set to a fixed value.")
43-
@click.option("--rt_norm_model", default = "nonlinear", show_default = True, type = click.Choice(['linear', 'nonlinear']), help = "Use linear or nonlinear model for RT normalizaiton.")
44-
@click.option("--score0_cutoff", default = "500", show_default = True, type = float, help = "Cut off value of score0.")
45-
@click.option("--score2_cutoff", default = "0.15", show_default = True, type = float, help = "Cut off value of score2.")
46-
@click.option("--out_chrom", is_flag = True, help = "Whether to output chromatograms for debugging.")
4762
@click.option("--decoy_method", default = "shuffle", show_default = True, type = click.Choice(["shuffle", "reverse", "pseudo_reverse", "shift", "mutate"]), help = "Decoy generation method.")
48-
def dreamScore(file_dir, lib, out, n_threads, seed, mz_unit, mz_min, mz_max, mz_tol_ms1, mz_tol_ms2, fdr_precursor, fdr_protein, n_irt, top_k, n_cycles, n_frags_each_precursor, do_not_output_library, model_cycles, n_lib_frags, n_self_frags, n_qt3_frags, n_ms1_frags, n_iso_frags, n_light_frags, prophet_mode, disc_model, dream_indicators, rt_norm_model, score0_cutoff, score2_cutoff, out_chrom, decoy_method):
49-
dream_score(file_dir, lib, out, n_threads, seed, mz_unit, mz_min, mz_max, mz_tol_ms1, mz_tol_ms2, fdr_precursor, fdr_protein, n_irt, top_k, n_cycles, n_frags_each_precursor, do_not_output_library, model_cycles, n_lib_frags, n_self_frags, n_qt3_frags, n_ms1_frags, n_iso_frags, n_light_frags, prophet_mode, disc_model, dream_indicators, rt_norm_model, score0_cutoff, score2_cutoff, out_chrom, decoy_method)
63+
@click.option("--ipf_scoring", is_flag = True, help = "Whether to calculate IPF scores.")
64+
def dreamScore(file_dir, lib, out, n_threads, seed, mz_unit, mz_min, mz_max, mz_tol_ms1, mz_tol_ms2, n_irts, irt_mode, irt_score_cutoff, irt_score_libcos_cutoff, rt_norm_model, n_cycles, n_frags_each_precursor, decoy_method, ipf_scoring):
65+
"""DreamDIA pipeline (Stage 1): scoring peaks of all runs."""
66+
dream_score(file_dir, lib, out, n_threads, seed, mz_unit, mz_min, mz_max, mz_tol_ms1, mz_tol_ms2, n_irts, irt_mode, irt_score_cutoff, irt_score_libcos_cutoff, rt_norm_model, n_cycles, n_frags_each_precursor, decoy_method, ipf_scoring)
67+
68+
@dreamdia.command(context_settings = CONTEXT_SETTINGS)
69+
@click.option("--dream_dir", required = True, type = click.Path(exists = True), help = "Output directory of `dreamscore`.")
70+
@click.option("--out", required = True, type = click.Path(exists = False), help = "Directory for output files.")
71+
@click.option("--n_threads", default = 16, show_default = True, type = int, help = "Number of threads.")
72+
@click.option("--seed", default = 12580, show_default = True, type = int, help = "Random seed.")
73+
@click.option("--top_k", default = "10", show_default = True, type = int, help = "Number of RSMs for each precursor to extract.")
74+
@click.option("--disc_model", default = "xgboost", show_default = True, type = click.Choice(["xgboost", "rf"]), help = "Type of the discriminative model.")
75+
@click.option("--disc_sample_rate", default = None, show_default = True, type = float, help = "Sample rate for building discriminative model.")
76+
@click.option("--fdr_precursor", default = "0.01", show_default = True, type = float, help = "FDR of precursor level.")
77+
@click.option("--fdr_peptide", default = "0.01", show_default = True, type = float, help = "FDR of peptide level.")
78+
@click.option("--fdr_protein", default = "0.01", show_default = True, type = float, help = "FDR of protein level.")
79+
@click.option("--dreamdialignr", is_flag = True, help = "Whether to activate DreamDIAlignR cross-run analysis.")
80+
@click.option("--r_home", default = None, show_default = True, type = click.Path(exists = True), help = "Directory of R home. (Required only when --dreamdialignr is specified.)")
81+
@click.option("--mra_algorithm", default = "dialignr", show_default = True, type = click.Choice(['dialignr', 'global']), help = "Multi-run alignment (MRA) algorithm. (Valid only when --dreamdialignr is specified.)")
82+
@click.option("--global_constraint_type", default = "lowess", show_default = True, type = click.Choice(['lowess', 'linear']), help = "Global alignment method. (Valid only when --dreamdialignr is specified.)")
83+
@click.option("--span_value", default = "0.1", show_default = True, type = float, help = "Span value of lowess fit. (Valid only when --dreamdialignr is specified and --global_constraint_type is set to 'lowess'.)")
84+
@click.option("--distance_metric", default = "nc", show_default = True, type = click.Choice(['nc', 'euclidean']), help = "Distance metric for global alignment of run pairs. (Valid only when --dreamdialignr is specified.)")
85+
@click.option("--rt_tol", default = "3.3", show_default = True, type = float, help = "RT tolerance for multi-run alignment. Should be unit cycle time. (Valid only when --dreamdialignr is specified.)")
86+
@click.option("--exp_decay", default = "50", show_default = True, type = float, help = "Exponential weight decay coeficient. (Valid only when --dreamdialignr is specified.)")
87+
def dreamProphet(dream_dir, out, n_threads, seed, top_k, disc_model, disc_sample_rate, fdr_precursor, fdr_peptide, fdr_protein, dreamdialignr, r_home, mra_algorithm, global_constraint_type, span_value, distance_metric, rt_tol, exp_decay):
88+
"""DreamDIA pipeline (Stage 2): identifying and quantifying peptides and proteins."""
89+
dream_prophet(dream_dir, out, n_threads, seed, top_k, disc_model, disc_sample_rate, fdr_precursor, fdr_peptide, fdr_protein, dreamdialignr, r_home, mra_algorithm, global_constraint_type, span_value, distance_metric, rt_tol, exp_decay)
90+
5091
if __name__ == "__main__":
51-
dreamdia()
92+
dreamdia()

0 commit comments

Comments
 (0)