Package: py-outrider
py_outriderpy_outrider is a flexible framework for outlier detection in omics datasets.How to startAfter cloning this repository, you can set up your own environment with all required packages using theenvironment.ymlor you run it using the following conda environment:conda activate outrider2(It is recommended to useTensorflow>2.0.2, which fixed some rather significant runtime issues.)Then, runpip install py_outriderto install py_outrider in this environment (orpip install git+https://github.com/gagneurlab/py_outrider.gitto install from github).
To check available options, runpy_outrider--helpOUTRIDERFor large data sets, the python version has a way faster fitting procedure of outrider as the R versionpy_outrider--inputcount_table.csv--encod_dim5--profileoutrider--outputOUTPUT_FILE--num_cpus10Be careful: input matrix must have the format: rows:samples x columns:genes, must be comma separated (csv), and needs the 1st row and 1st column to contain the feature and sample names, respectivelyPROTRIDERMore accurate (but with longer runtime) fitting method for proteins with covariate considerationpy_outrider--inputprotein_intensities.csv--encod_dim5--profileprotrider--outputOUTPUT_FILE--num_cpus10--sample_annosample_anno.csv-covbatchgender--output_res_tableRESULTS_TABLE_FILEMissing values due to missing detection in the mass-spectrometry must be declared as such, e.g. NAN and must not be kept 0, as this will be considered as true value.Outputpy_outrider outputs an AnnData object containing the data, fit results, p values etc. (by default as an .h5ad file).
To read in the output file, and access e.g. adjusted pvalues, runimportanndataadata=anndata.read("/path/to/py_outrider_results.h5ad")adata.layers["X_padj"]Output matrices include:NameDescriptionX_pvaluecalculated p valuesX_padjcaluclated adjusted p valuesoutrider_fccalculated fold-changesoutrider_l2fccalculated log2 fold-changesoutrider_zscorecalculated zscoresoutrider_deltacalculated delta values (obs - exp)X_rawinput matrix (same asadata.X)X_preprocontains the result of applying the preprocessing function (inadata.uns["prepro_func"]) toX_raw(equal toX_rawif no preprocessing)X_sf_normsizefactor normalization applied toX_preproX_transformedcontains the result of applying the transformation function (inadata.uns["transform_func"]) toX_sf_norm(orX_preprowhen sf_norm=False)X_AE_inputinput matrix to the AE model, including covariates if requested (X_transformedcentered feature-wise if centering=True)X_predicted_no_transoutput of AE model before reverse transforming (compare withX_transformed)X_predictedexpected values, output of AE model after reverse transforming and multiplying with sizefactors (compare withX_prepro)X_latentcomputed latent space (samples x encod_dim); access withadata.obsm["X_latent"]dispersionscalculated dispersions (= theta for NB); access withadata.varm["dispersions"]Additionally, py_outrider writes a results table to a specified csv file if the option--output_res_tabe /PATH/TO/RESULTS_TABLE.CSVis set.Usageusage: py_outrider [-h] [-in INPUT] [-sa SAMPLE_ANNO] [-o OUTPUT]
                   [-ot {h5ad,csv,zarr}] [-or OUTPUT_RES_TABLE]
                   [-p {outrider,protrider,pca}] [-q ENCOD_DIM]
                   [-cov [COVARIATES [COVARIATES ...]]] [-i ITERATIONS]
                   [-fl {float32,float64}] [-cpu NUM_CPUS] [-v VERBOSE]
                   [-s SEED] [-dis {NB,gaussian,log-gaussian}]
                   [-ld {NB,gaussian,log-gaussian}] [-pre {none,log}]
                   [-sf SF_NORM] [-c CENTERING] [-dt {log1p,log,none}]
                   [-nf NOISE_FACTOR] [--latent_space_model {AE,PCA}]
                   [--decoder_model {AE,PCA}] [--dispersion_model {ML,MoM}]
                   [--optimizer {lbfgs}] [--batch_size BATCH_SIZE]
                   [--nr_latent_space_features NR_LATENT_SPACE_FEATURES]
                   [--parallelize_D] [--no_parallelize_D]
                   [--convergence CONVERGENCE]
                   [--effect_type [{none,zscores,fold_change,delta} [{none,zscores,fold_change,delta} ...]]]
                   [--fdr_method FDR_METHOD] [--max_iter_hyper MAX_ITER_HYPER]
                   [--convergence_hyper CONVERGENCE_HYPER]

Run py_outrider to detect aberrant events in omics data.

optional arguments:
  -h, --help            show this help message and exit
  -in INPUT, --input INPUT
                        Path to a file containing the input data matrix, like
                        a gene count table. Can either be a csv file with
                        format: rows:samples x columns:genes and 1. row and 1.
                        column having feature and sample names, respectively;
                        or a .h5ad file containing an existing AnnData object
                        .
  -sa SAMPLE_ANNO, --sample_anno SAMPLE_ANNO
                        Path to sample annotation file, must be comma
                        separated, automatically selects sampleID column as
                        the one which has input_file rownames in it.
  -o OUTPUT, --output OUTPUT
                        Filename to save results (adata object).
  -ot {h5ad,csv,zarr}, --output_type {h5ad,csv,zarr}
                        File type of the output (h5ad, csv or zarr). Default:
                        h5ad
  -or OUTPUT_RES_TABLE, --output_res_table OUTPUT_RES_TABLE
                        Outputs results table as csv to the specifed file.
  -p {outrider,protrider,pca}, --profile {outrider,protrider,pca}
                        Choose which pre-defined implementation should be
                        used. Default profile: outrider
  -q ENCOD_DIM, --encod_dim ENCOD_DIM
                        Number of encoding dimensions. If not specified, runs
                        hyperparameter optimization to determine best encoding
                        dimension.
  -cov [COVARIATES [COVARIATES ...]], --covariates [COVARIATES [COVARIATES ...]]
                        List of covariate names in sample_anno, can either be
                        columns filled with 0 and 1, multiple numbers or
                        strings (will be automatically converted to one-hot
                        encoded matrix for training).
  -i ITERATIONS, --iterations ITERATIONS
                        [predefined in profile] Number of maximal training
                        iterations. Default: 15
  -fl {float32,float64}, --float_type {float32,float64}
                        [predefined in profile] Which float type should be
                        used, highly advised to keep float64 which may take
                        longer, but accuracy is strongly impaired by float32.
                        Default: float64
  -cpu NUM_CPUS, --num_cpus NUM_CPUS
                        Number of cpus used. Default: 1
  -v VERBOSE, --verbose VERBOSE
                        Set this flag to enable printing of additional
                        information during model fitting.
  -s SEED, --seed SEED  Seed used for training, negative values (e.g. -1) ->
                        no seed set. Default: 7
  -dis {NB,gaussian,log-gaussian}, --distribution {NB,gaussian,log-gaussian}
                        [predefined in profile] distribution assumed for the
                        measurement data.
  -ld {NB,gaussian,log-gaussian}, --loss_distribution {NB,gaussian,log-gaussian}
                        [predefined in profile] loss distribution used for
                        training.
  -pre {none,log}, --prepro_func {none,log}
                        [predefined in profile] preprocessing function applied
                        to input data. Distribution should be applicable for
                        the preprocessed data.
  -sf SF_NORM, --sf_norm SF_NORM
                        [predefined in profile] Boolean value indicating
                        whether sizefactor normalization should be performed.
  -c CENTERING, --centering CENTERING
                        [predefined in profile] Boolean value indicating
                        whether input should be centered before model fitting.
  -dt {log1p,log,none}, --data_trans {log1p,log,none}
                        [predefined in profile] transformation function
                        applied to preprocessed input data to create input for
                        AE model.
  -nf NOISE_FACTOR, --noise_factor NOISE_FACTOR
                        [predefined in profile] factor which defines the
                        amount of noise applied for a denoising autoencoder
                        model.
  --latent_space_model {AE,PCA}
                        [predefined in profile] Sets the model for fitting the
                        latent space.
  --decoder_model {AE,PCA}
                        [predefined in profile] Sets the model for fitting the
                        decoder.
  --dispersion_model {ML,MoM}
                        [predefined in profile] Sets the model for fitting the
                        dispersion parameters. Either ML for maximum
                        likelihood fit or MoM for methods of moments. Has no
                        effect for loss distributions that do not have
                        dispersion parameters.
  --optimizer {lbfgs}   [predefined in profile] Sets the optimizer for model
                        fitting. Currently only L-BFGS is implemented.
  --batch_size BATCH_SIZE
                        batch_size used for model fitting. Default is to use
                        all samples.
  --nr_latent_space_features NR_LATENT_SPACE_FEATURES
                        Limits the number of features used for fitting the
                        latent space to the specified number k. The k most
                        variable features will be selected. Default is to use
                        all features.
  --parallelize_D       If this flag is set, parallelizes fitting of decoder
                        per feature. Default: True (do parallelize by
                        feature).
  --no_parallelize_D    If this flag is set, decoder fit will not be
                        parallelized per feature. Default: do parallelize by
                        feature.
  --convergence CONVERGENCE
                        Sets the convergence limit. Default value is 1e-5.
  --effect_type [{none,zscores,fold_change,delta} [{none,zscores,fold_change,delta} ...]]
                        [predefined in profile] Chooses the type of effect
                        size that is calculated. Specifying multiple options
                        is possible.
  --fdr_method FDR_METHOD
                        Sets the fdr adjustment method. Must be one of the
                        methods from
                        statsmodels.stats.multitest.multipletests. Defaults to
                        fdr_by.
  --max_iter_hyper MAX_ITER_HYPER
                        Number of maximial training iterations during hyper
                        parameter optimization. Default: 15
  --convergence_hyper CONVERGENCE_HYPER
                        Convergence limit used during hyper parameter
                        optimization. Default: 1e-5