It works using pipeline files to describe the steps that are needed, the script is then simply launched from main like this:
source("R/init.r")
main("path/pipeline_file.json")
To load the information about the subjects a file with the necessary info must be written, it is a text file with a very easy syntax. The path to the file must then be specified in the loading page. The spaces between the - must also be respected
example
subjectID - group
...
It specifies the parameters that are used in the pipeline, the settable parameters are described in settings file.
The pipeline sections are executed in the order in which they are described below. a "pipeline" section is necessary with at least one element set to true. The general settings section is also required, with at least the destination folder and the path to the settings file defined. The settings file contains all the default settings for the pipelines, if they are not overridden in the pipeline file, these are the settings that are used. The settings file needs to be created for each project, the pipeline files for each analysis that needs to be performed.
This document outlines the structure and functionality of a pipeline for data preprocessing, integration, and analysis. The pipeline consists of multiple steps, each of which can be executed independently by setting corresponding parameters in the configuration file.
The preprocessing step loads data from a specified folder, processes it with DoubletFinder, and creates Seurat objects. If the save parameter is enabled, these objects can be saved in the save_namelocation.
Following preprocessing, Seurat objects can be merged and integrated using Harmony. As with preprocessing, the final Seurat object can be saved in the save_namelocation if the save parameter is set.
This section covers basic operations such as clustering, dimensionality reduction plotting, and cluster annotation. Each operation is controlled by specific parameters and can be run multiple times.
method: plotting
Visualize the results of clustering or annotation using UMAP dimensionality reduction.
- umap: Specifies the name of the reduction slot for UMAP. Defaults to
umapif not provided. - compute_UMAP:
[true | false]— Whether to compute a new UMAP. Iffalse, a pre-existing UMAP is required. - reduction: Specifies the reduction method for UMAP. Defaults to the global
rparameter. - cluster_column: Specifies the column to use for cluster names. Defaults to the global
cparameter. - save: Whether to save the resulting object.
- save_name: The name under which the object will be saved.
method: annotation
Clusters can be annotated either automatically using scType or manually using a defined mapping.
- auto:
[true | false]— Whentrue, clusters are automatically annotated withscType. If no manual annotation is provided via theto_annotateparameter, this must be set totrue. - to_annotate: Mapping of existing cluster names to new names, saved in the
annotation_column. Defined as r list, (like python dictionary), in JSON as a standard object. - annotation_column: The column where annotations are saved (applies to both automatic and manual annotations).
- corrected_annotation_column: The column where the corrected annotations are saved, if it is not given the annotation_column is updated
- cluster_column: The source column for clustering results, used in both automatic and manual annotation. Defaults to the global
cparameter. - save: Whether to save the resulting object.
- save_name: The name under which the object will be saved.
method: clustering
Executes Louvain clustering with Seurat’s algorithm, storing results in the metadata in the given column
- desired_resolution: The resolution for Louvain clustering. Defaults to the global
dsrdparameter. - reduction: The reduction method used for clustering. Defaults to the global
rparameter. - cluster_column: Column where clustering results will be stored. Defaults to the global
cparameter. - save: Whether to save the resulting object.
- save_name: The name under which the object will be saved.
The Seurat object can be subset based on specific clusters, with the option for manual correction. The parameters for this step are:
- save: Whether to save the resulting object.
- save_name: The name under which the object will be saved.
- cluster_column: The cluster column used for subsetting.
- subset: Specifies which clusters to keep in the subset, defined as array.
Different methods are available for identifying differentially expressed genes (DEGs). Each method can be run multiple times with different settings.
- feature_plots_top9_deg: make a plot of the top 9 genes according to adjusted pvalue, the umap used is the one defined in the global variables
- method: the method to use, an option for a normal markers analysis can be selected or one of the additional methods (volcano, paper, other_plots_from_df, heatmap)
-
heatmap: Generates a heatmap from a list of markers or from DEGs if no markers are provided.
- cluster_column: The column containing the annotation for the plot.
- markers: A list of markers for the heatmap.
- clusters: Specifies clusters to visualize.
- maxn_genes: Maximum number of genes to plot (default 100).
- n_genes: Number of genes per cluster (default 25).
- maxn_genes_per_plot: Maximum genes per plot (default 100).
- sorting_method: method to sort the found markers for filtering, only the top n are plotted according to this metric.
-
volcano: Creates a volcano plot from the table in the
folderspecified for DEG analysis. -
plots_misc: Generates plots for various Seurat object properties.
- markers: A list of markers for feature and ridge plots.
- cluster_column: Metadata column for the plot.
- subplot_n: Number of subplots for the feature plot.
- which_other: Specifies additional plots such as bar or pie charts. (names to be given in an r array)
- umap_name: umap reduction to use for visualisation, if not given uses default in global parameters
-
other_plots_from_df: Plots markers from a dataframe. Possibilities are: -
feature plotplot, setting the feature_plot variable to true, also the number of genes per feature plots can be selected -heatmap, setting the plot_heatmap variable to true, this can be done with one heatmapp for each table column or for all in one heatmap parameters needed- plot_heatmap: To be set to true or false
- markers: Excel file containing markers.
- cluster_column: Metadata column for plotting.
- subplot_n: Number of subplots for feature plots.
- heatmap: Option to plot a heatmap.
- feature_plot: Option to plot feature plots.
- heatmap_by_column: If
true, generates one heatmap per dataframe column. - subplot_n: maximum number of subplots per feature plot (suggested 9 or 4)
- max_feature_plots: maximum number of feature plots, if there are hundreds of genes in the dataframe the feature plots can be very long to generate, hence this parameter
- max_genes: max genes per heatmap, if there are more genes another heatmap is generated
- column_list: for which column of the dataframe are the plots created? if empty all the columns. if plotting the results of deg set this value to ["gene"]
-
violin_plots: makes the violin plot, either from a list of markers given or from an excel file specified by marker analysis(folder) and cluster (file), in this case only the n max_genes ordered by absolute avg log2fc is plotted
- markers
- cluster
- markers_analysis
- max_genes
WGCNA analysis can be run multiple times with different settings. If the cluster column is not defined the default c (in global settings) is used. Parameters for WGCNA are:
Enrichment analysis can be performed using one of four methods, depending on the parameters set:
- General DEG Results: Enrichment based on all DEGs. If only the folder of the DEG analysis is provided.
- Excluding a WGCNA Module: Runs enrichment analysis excluding a specific WGCNA module. It is set by proiding the parameter wgcna_exclude
- Single WGCNA Module: Runs enrichment on selected WGCNA modules. If the selected wgcna modules are provided it is run on those, if they are over the module threshold. If the wgcna modules are not provided it is run only on those which respect the condition of having a sufficient number of genes in the module (the parameter
module_thresholddecides this, the default value is 500). - Linear Model in WGCNA: Runs enrichment on WGCNA modules selected via a linear model. If a module significance table computed with the wgcna section is provided.
The enrichment can also be done for a single cluster by setting the parameter cluester and if necessary cluster_column
The possible methods are:
- GSEA: using clusterProfiler
- ORA: using clusterProfiler
- enrichr: using rbioapi
- panther: using rbioapi
ClusterProfiler: https://bioconductor.org/packages/release/bioc/html/clusterProfiler.html
rbioapi: https://cran.r-project.org/web/packages/rbioapi/vignettes/rbioapi.html
for preprocessing,integration,clustering,annotation: need to be specified in the apposite section
for: deg,wgcna,enrichment: need to be specified in the subsection for the name of the analysis, for each pipeline can be run multiple times. The folder with the results will be called with the same name of the subsection in which the settings are in.
tip: if you create a section in the settings that does not have one of the names here descrbed it will not be run example:
"enrichment": {
"WGCNA_all": {
"markers_path": "markers_microglia_control_vs_pd",
"modules_significance_table":"linear_model_significance_membership_single_module_frontal_cortex_thickness.xlsx",
"wgcna_folder": "WGCNA_all/"
},
"WGCNA_0": {
"markers_path": "markers_microglia_control_vs_pd_clusters",
"cluster": 2,
"modules_significance_table":"linear_model_significance_membership_single_module_frontal_cortex_thickness.xlsx",
"wgcna_folder": "WGCNA_cluster0/"
},
"WGCNA_2": {
"markers_path": "markers_microglia_control_vs_pd_clusters",
"cluster": 2,
"modules_significance_table":"linear_model_significance_membership_single_module_frontal_cortex_thickness.xlsx",
"wgcna_folder": "WGCNA_cluster2/"
}
}
The settings file stores the default parameters for each pipeline that is run. All the parameters specified in the pipeline files are overwritten when the pipeline is run. This file can serve as template when creating a pipeline file.
parameter[type] -default (example)
seurat_object[boolean] -falsefolder_destination[string | null] -nulldata_folder[boolean] -falsesettings_path[string | null] -null
count_matrix_pattern[string] -"filtered_feature_bc_matrix"r_before_integration[string] -"pca"c_before_integration[string] -"clusters"patient_info[string] -"input/info_subj.txt"r[string] -"harmony_reduction"c[string] -"harmony_clusters"a[string] -"RNA"umap[string] -"umap_microglia_harmony_reduction"dstd[float] -1.5d[float] -0.3name[string] -"only_omics_subjects"annotation[string] -"microglia_clusters"corrected_annotation[string] -"microglia_clusters_scType"extension_plot[string] -".png"
save[boolean] -truesave_name[string] -"after_preprocessing"parts_to_remove[string] -"_filtered_feature_bc_matrix"
save[boolean] -truesave_name[string] -"after_integration.rds"method[string] -"harmony"
method[string|null] -nullauto_annotation[boolean] -falseannotation_column[string|boolean] -"column_annotation"(can be also set to false to use the value in the global settings)correct_annotation[boolean] -falsecorrect_annotation_column[string|boolean] -"column_correct_annotation"(can be also set to false to use the value in the global settings)to_correct[boolean] -falsecluster_column[string|boolean] -"column_cluster"(can be also set to false to use the value in the global settings)resolution[boolean] -falseexplained_variance[boolean] -falsereduction[boolean] -falseumap_name[string|boolean] -"harmony_umap"(can be also set to false to use the value in the global settings)compute_umap[boolean] -falsesave[boolean] -falsesave_name[string] -"main_pipeline_default.rds"
markers_path[string|null] -nullcount_threshold[integer] -0wgcna_folder[boolean] -falsewgcna_module[boolean] -falsemodules_significance_table[boolean] -falsemodule_threshold[integer] -500wgcna_exclude[boolean] -falsecluster[boolean] -falseminGSsize[integer] -15maxGSsize[integer] -500organism[string] -"9606"taxonomynum_tries[integer] -3raw[boolean] -falseextension_plot[string] -".png"scoring[string] -"log2FC"n_gene_enrich[integer] -300
method[string] -"WGCNA"cluster[list|false] -falsewgcna_file[string] -"bwnet.rds"save_net[boolean] -falseload_net[boolean] -falsesoft_power[boolean] -falsesubject_pathology_column[string] -"subject_pathology"subject_column[string] -"subject"extension_plot[string] -".png"markers_analysis[string] -"group1_group2"hub_gene_threshold[array] -[0.3, 1]which[array] -[]type[string] -"unsigned"TOMType[string] -"unsigned"mergeCutHeight[float] -0.25minModuleSize[integer] -50wgcna_subjects[object] -{ "PD_001": "02_082" }regions[array] -["superiorfrontal", "caudalmiddlefrontal", "rostralmiddlefrontal"]regions_plot[array] -[]data_source_mri[string] -"aparc"
heatmap_pathologyCorrelation heatmap.TOMTopological overlap matrix (to be developed).dendroDendrogram (to be developed).heatmap_mriMRI correlation heatmap.heatmap_zscoreZ-score correlation heatmap.violin_plotsViolin plots for gene expression by condition. for each condition the genes which show the lowest pvalue of the correlation with it (the trait)histogram_plotHistogram of gene expression by module. (log2fc)histogram_plot_significanceHistogram plot of gene significancesignificance_membership_scatterScatter plot of significance and membership.significance_log2fc_scatterScatter plot of significance and log2 fold change.correlation_avglog2fc_scatterScatter plot of correlation to traits and log2 fold change.corr_matrix: plot the correlation matrix between moduelessignificance_membership_modelLinear model between significance and membership.
save_data[boolean] -truecluster_column[string] -"harmony_clusters"method[string] -"default"subset_id[string] -"control"condition[string] -"group1"nothreshold[boolean] -falsecontrol[string] -"control"condition_column[string] -"subject_pathology"folder[boolean] -falseumap_name[boolean] -falsemodules_significance_table[boolean] -falsemarkers[boolean] -falseheatmap[boolean] -truefeature_plot[boolean] -falseheatmap_by_column[boolean] -falsesubplot_n[integer] -9max_feature_plots[integer] -11max_genes_heatmap[integer] -100column_list[array] -[]sorting_method[string] -"abs"feature_plots_top9_deg[boolean] -falsecluster[boolean] -falsemarkers_analysis[string] -"group1_group2"
condition_and_clusters: Compares markers between clusters.condition_and_clusters_vf: Similar, but only considers variable features.default: Finds markers between clusters.default_vf: Finds markers between clusters but only for variable features.condition: Compares markers between different groups.condition_vf: Compares markers between groups but only for variable features.
plots_misc: a variety of plotting methods for properties of the objectheatmap: heatmap of the expression of a predefined list of genesother_plots_from_df: heatmap and feature plots from an external gene listvolcano: creates a volcano plot in a folder with a deg results table
numberofcell_barplot:numberofcell_pie_chart:numberofcell_barplot_subject:numberofcell_pie_chart_subject:numberofcell_pie_chart_cluster_subject:numberofcell_pie_chart_cluster_pathology:feature_plot: plots the feature plots with the given markersridge_plots: plots the ridge plots of the expresison of the given markers
path[string | null] -null
to write your own script, the own script parametr needs to be set to true, the global settings can be set and also the specific settings (but in this case there no practical difference between the two, apart from the way they need to be accessed) The global settings are accessed by simply writing the variable name how it is written in the pipeline file, the sepcific settings are accessed with parameters$variable_name. If you want the seurat object to be preloaded for you you can just set it in the gloab variables, otherwie just dont set anything or leave it to false.