-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #372 from AlexsLemonade/development
Release v0.1.6 - data integration module
- Loading branch information
Showing
18 changed files
with
1,321 additions
and
248 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 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 |
---|---|---|
|
@@ -7,5 +7,6 @@ | |
# | ||
# library(dplyr) | ||
# | ||
library(uwot) | ||
library(remotes) | ||
library(markdown) | ||
library(uwot) |
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,11 @@ | ||
# All parameters included in this file can be altered at the command line using the `--config` flag or by editing this file directly. | ||
|
||
### Project-specific parameters | ||
results_dir: "example-results" | ||
integration_project_metadata: "example-data/project-metadata/example-integration-library-metadata.tsv" | ||
|
||
### Processing parameters | ||
threads: 1 # number of multiprocessing threads to use | ||
integration_method: "fastMNN,harmony" # method(s) to be used for integration | ||
batch_column: "library_id" # the name of the SCE column that contains batch labels | ||
cell_id_column: "cell_id" # the name of the SCE column variable indicating the original cell barcode |
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
3 changes: 3 additions & 0 deletions
3
example-data/project-metadata/example-integration-library-metadata.tsv
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,3 @@ | ||
sample_id library_id processed_sce_filepath integration_group | ||
sample01 library01 example-results/sample01/library01_processed.rds group01 | ||
sample02 library02 example-results/sample02/library02_processed.rds group01 |
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,81 @@ | ||
import pandas as pd | ||
|
||
configfile: "config/config.yaml" | ||
configfile: "config/integration_config.yaml" | ||
|
||
# getting the samples information | ||
if os.path.exists(config['integration_project_metadata']): | ||
samples_information = pd.read_csv(config['integration_project_metadata'], sep='\t', index_col=False) | ||
|
||
# get a list of the file paths and integration groups | ||
GROUP = list(samples_information['integration_group']) | ||
else: | ||
# If the metadata file is missing, warn and fill with empty lists | ||
print(f"Warning: Project metadata file '{config['integration_project_metadata']}' is missing.") | ||
samples_information = None | ||
GROUP = list() | ||
|
||
rule target: | ||
input: | ||
expand(os.path.join(config["results_dir"], "{group}_integrated_sce.rds"), | ||
zip, | ||
group = GROUP), | ||
expand(os.path.join(config["results_dir"], "{group}_integration_report.html"), | ||
zip, | ||
group = GROUP) | ||
|
||
rule merge_sces: | ||
input: | ||
config["integration_project_metadata"] | ||
output: | ||
temp(os.path.join(config["results_dir"], "{group}_merged_sce.rds")) | ||
log: os.path.join("logs", config["results_dir"], "{group}_merge_sce.log") | ||
conda: "envs/scpca-renv.yaml" | ||
shell: | ||
" Rscript --vanilla 'optional-integration-analysis/merge-sce.R'" | ||
" --input_metadata_tsv {input}" | ||
" --integration_group {wildcards.group}" | ||
" --output_sce_file {output}" | ||
" --n_hvg {config[n_genes_pca]}" | ||
" --threads {config[threads]}" | ||
" --project_root $PWD" | ||
" &> {log}" | ||
|
||
rule perform_integration: | ||
input: | ||
"{basedir}/{group}_merged_sce.rds" | ||
output: | ||
"{basedir}/{group}_integrated_sce.rds" | ||
log: "logs/{basedir}/{group}_perform_integration.log" | ||
conda: "envs/scpca-renv.yaml" | ||
shell: | ||
" Rscript --vanilla 'optional-integration-analysis/perform-integration.R'" | ||
" --merged_sce_file {input}" | ||
" --integration_method {config[integration_method]}" | ||
" --fastmnn_auto_merge" | ||
" --output_sce_file {output}" | ||
" --project_root $PWD" | ||
" &> {log}" | ||
|
||
rule generate_integration_report: | ||
input: | ||
integrated_sce = "{basedir}/{group}_integrated_sce.rds" | ||
output: | ||
"{basedir}/{group}_integration_report.html" | ||
log: "logs/{basedir}/{group}/integration_report.log" | ||
conda: "envs/scpca-renv.yaml" | ||
shell: | ||
""" | ||
Rscript --vanilla -e " | ||
rmarkdown::render('optional-integration-analysis/integration-report-template.Rmd', | ||
clean = TRUE, | ||
output_file = '{output}', | ||
output_dir = dirname('{output}'), | ||
params = list(integration_group = '{wildcards.group}', | ||
integrated_sce = '{input.integrated_sce}', | ||
integration_method = '{config[integration_method]}', | ||
batch_column = '{config[batch_column]}', | ||
cell_id_column = '{config[cell_id_column]}'), | ||
envir = new.env()) | ||
" &> {log} | ||
""" |
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
Oops, something went wrong.