-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding normalize step to recipe #16
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os | ||
import sys | ||
import pathlib | ||
import argparse | ||
import warnings | ||
import pandas as pd | ||
|
||
from pycytominer import normalize | ||
|
||
sys.path.append("../scripts") | ||
from config_utils import process_config_file | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--config_file", | ||
help="configuration yaml file for the profiling pipeline", | ||
default="profiling_config.yaml", | ||
) | ||
args = parser.parse_args() | ||
config_file = args.config_file | ||
|
||
config = process_config_file(config_file) | ||
|
||
# Extract config arguments | ||
core_args = config["core"] | ||
batch = core_args["batch"] | ||
aggregate_args = config["aggregate"] | ||
normalize_args = config["normalize"] | ||
|
||
ignore_files = core_args["ignore_files"] | ||
float_format = core_args["float_format"] | ||
compression = core_args["compression"] | ||
|
||
normalize_singlecell_from_single_file = core_args["output_one_single_cell_file_only"] | ||
normalize_levels = normalize_args["levels"] | ||
normalize_by_samples = normalize_args["by_samples"] | ||
normalize_these_features = normalize_args["features"] | ||
normalize_method = normalize_args["method"] | ||
normalize_input_files = aggregate_args["aggregate_output_files"] | ||
normalize_output_files = normalize_args["normalize_output_files"] | ||
|
||
for data_level in normalize_levels: | ||
if data_level == "single_cell": | ||
if not normalize_singlecell_from_single_file: | ||
continue | ||
|
||
file_to_normalize = normalize_input_files[data_level] | ||
output_file = normalize_output_files[data_level] | ||
|
||
print(f"Now normalizing {data_level}...with operation: {normalize_method}") | ||
|
||
normalize_df = normalize( | ||
profiles=file_to_normalize, | ||
features=normalize_these_features, | ||
samples=normalize_by_samples, | ||
method=normalize_method, | ||
output_file=output_file, | ||
compression=compression, | ||
float_format=float_format, | ||
) |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everywhere else so far we've set config defaults to single folders instead of nested folders.
Do we need to maintain this in case someone is working in an OS that uses \ not / ? Though I guess we have / at the end of all of our paths, so never mind on that remark.
I guess I just want to point this out and it's not necessarily a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch - yes this is definitely something to be mindful of. Fortunately,
pathlib
is great and will take care of that issue under the hood.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note that we are modeling the directory structure in this project from cytomining/profiling-handbook#54 (comment)