-
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.
reformatted cbioportal pipeline for nextflow compatibility (#13)
* reformatted cbioportal pipeline for nextflow compatibility * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * minor in progress changes in process_cbioportal.nf * added shebang to process_cbioportal.py * updated cbioportal scripts to conform to NF ETL pipeline * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * interim commit for transform_cbioportal resolved conflicts in cbioportal.py * added transform_cbioportal CLI code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * .gitignore and pyproject.toml changes for transform_cbioportal CLI changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1f1e326
commit 000fab3
Showing
13 changed files
with
415 additions
and
120 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
Empty file.
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,76 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
|
||
from missense_kinase_toolkit import config, cbioportal | ||
|
||
def parsearg_utils(): | ||
parser = argparse.ArgumentParser( | ||
description="Get mutations from cBioPortal cohort and instance" | ||
) | ||
|
||
parser.add_argument( | ||
"--cohort", | ||
type=str, | ||
help="Optional: cBioPortal cohort IDs separated by commas (e.g., `msk_impact_2017` for Zehir, 2017 and `mskimpact` for MSKCC clinical sequencing cohort) (str)", | ||
default="msk_impact_2017", | ||
) | ||
|
||
parser.add_argument( | ||
"--outDir", | ||
type=str, | ||
help="Required: Output directory path (str)", | ||
) | ||
|
||
parser.add_argument( | ||
"--instance", | ||
type=str, | ||
help="Optional: cBioPortal instance (e.g., `cbioportal.mskcc.org`). Default: `www.cbioportal.org` (str)", | ||
default="www.cbioportal.org", | ||
) | ||
|
||
parser.add_argument( | ||
"--token", | ||
type=str, | ||
default="", | ||
help="Optional: cBioPortal API token (str)", | ||
) | ||
|
||
# parser.add_argument( | ||
# "--requestsCache", | ||
# type=str, | ||
# default="", | ||
# help="Optional: Requests cache (str)", | ||
# ) | ||
|
||
# TODO: add logging functionality | ||
return parser | ||
|
||
|
||
def main(): | ||
args = parsearg_utils().parse_args() | ||
|
||
str_studies = args.cohort | ||
list_studies = str_studies.split(",") | ||
list_studies = [study.strip() for study in list_studies] | ||
|
||
# required argument | ||
config.set_output_dir(args.outDir) | ||
|
||
# optional arguments | ||
config.set_cbioportal_instance(args.instance) | ||
|
||
try: | ||
if args.token != "": | ||
config.set_cbioportal_token(args.token) | ||
except AttributeError: | ||
pass | ||
|
||
# try: | ||
# if args.requestsCache != "": | ||
# config.set_request_cache(args.requestsCache) | ||
# except AttributeError: | ||
# pass | ||
|
||
for study in list_studies: | ||
cbioportal.get_and_save_cbioportal_cohort(study) |
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,70 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
|
||
from missense_kinase_toolkit import config, scrapers, io_utils | ||
|
||
|
||
def parsearg_utils(): | ||
parser = argparse.ArgumentParser( | ||
description="Concatenate, remove duplicates, and extract genes and mutation types of interest" | ||
) | ||
|
||
parser.add_argument( | ||
"--mutations", | ||
type=str, | ||
help="Optional: Mutation type(s) to extract, separated by commas (e.g., `Missense_Mutation`) (str)", | ||
default="", | ||
) | ||
|
||
parser.add_argument( | ||
"--outDir", | ||
type=str, | ||
help="Required: Output directory path (str)", | ||
) | ||
|
||
parser.add_argument( | ||
"--requestsCache", | ||
type=str, | ||
default="", | ||
help="Optional: Requests cache (str)", | ||
) | ||
|
||
# TODO: add logging functionality | ||
return parser | ||
|
||
|
||
def main(): | ||
args = parsearg_utils().parse_args() | ||
|
||
str_mutations = args.mutations | ||
list_mutations = str_mutations.split(",") | ||
list_mutations = [mutation.strip() for mutation in list_mutations] | ||
|
||
# required argument | ||
config.set_output_dir(args.outDir) | ||
|
||
try: | ||
if args.requestsCache != "": | ||
config.set_request_cache(args.requestsCache) | ||
except AttributeError: | ||
pass | ||
|
||
df_cbioportal = io_utils.concatenate_csv_files_with_glob("*_mutations.csv") | ||
|
||
df_kinhub = scrapers.kinhub() | ||
io_utils.save_dataframe_to_csv(df_kinhub, "kinhub.csv") | ||
|
||
list_kinase_hgnc = df_kinhub["HGNC Name"].to_list() | ||
|
||
df_subset = df_cbioportal.loc[df_cbioportal["mutationType"].isin(list_mutations), ].reset_index(drop=True) | ||
df_subset = df_subset.loc[df_subset["hugoGeneSymbol"].isin(list_kinase_hgnc), ].reset_index(drop=True) | ||
|
||
list_cols = ["HGNC Name", "UniprotID"] | ||
df_subset_merge = df_subset.merge(df_kinhub[list_cols], | ||
how = "left", | ||
left_on = "hugoGeneSymbol", | ||
right_on = "HGNC Name") | ||
df_subset_merge = df_subset_merge.drop(["HGNC Name"], axis=1) | ||
|
||
io_utils.save_dataframe_to_csv(df_subset_merge, "transformed_mutations.csv") |
Oops, something went wrong.