-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
448 additions
and
224 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
|
||
# Reproducible analyses | ||
|
||
The scripts in this directory reproduce the analyses of the curated datasets. They were written as a record of usage of the dashboard web application, which provides the same results. | ||
The scripts in this directory reproduce the analyses of the curated datasets, in the order they are mentioned in the article. | ||
|
||
You can run them on the public demo API, | ||
These scripts were written as a record of usage of the dashboard web application, which provides the same results. | ||
|
||
You can run them on the public demo API: | ||
|
||
```sh | ||
python reproducible_analyses/melanoma_il2.py oncopathtk.org/api | ||
python run_all.py http://oncopathtk.org/api | ||
``` | ||
|
||
or from your own local instance of the application, | ||
Or you can run them from your own local instance of the application: | ||
|
||
```sh | ||
python reproducible_analyses/melanoma_il2.py "127.0.0.1:8080" | ||
python run_all.py "http://127.0.0.1:8080" | ||
``` | ||
|
||
substituting the argument with the address of your local API server. (See *Setting up a local application instance*). | ||
|
||
- These scripts just call the web API, and so they do not require Python package `spatialprofilingtoolbox`. | ||
- You can alternatively store the API host in `api_host.txt` and omit the command-line argument above. | ||
- The run result is here in [results.txt](results.txt). |
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 |
---|---|---|
@@ -1,57 +1,64 @@ | ||
"""Data analysis script for one dataset.""" | ||
|
||
import sys | ||
|
||
from numpy import mean | ||
from numpy import inf | ||
|
||
from accessors import DataAccessor | ||
from accessors import get_default_host | ||
from accessors import univariate_pair_compare as compare | ||
|
||
def test(host): | ||
study = 'Breast cancer IMC' | ||
access = DataAccessor(study, host=host) | ||
|
||
KRT = { | ||
'5': {'positive_markers': ['KRT5', 'CK'], 'negative_markers': []}, | ||
'7': {'positive_markers': ['KRT7', 'CK'], 'negative_markers': []}, | ||
'14': {'positive_markers': ['KRT14', 'CK'], 'negative_markers': []}, | ||
'19': {'positive_markers': ['KRT19', 'CK'], 'negative_markers': []}, | ||
} | ||
|
||
df = access.proximity([KRT['14'], KRT['7']]) | ||
values1 = df[df['cohort'] == '1']['proximity, KRT14+ CK+ and KRT7+ CK+'] | ||
values2 = df[df['cohort'] == '2']['proximity, KRT14+ CK+ and KRT7+ CK+'] | ||
# handle_expected_actual(1.6216, mean2 / mean1) | ||
# # handle_expected_actual(1.69, mean2 / mean1) | ||
compare(values1, values2, expected_fold=1.6216, show_pvalue=True) | ||
|
||
df = access.proximity([KRT['14'], KRT['5']]) | ||
values2 = df[df['cohort'] == '2']['proximity, KRT14+ CK+ and KRT5+ CK+'] | ||
values3 = df[df['cohort'] == '3']['proximity, KRT14+ CK+ and KRT5+ CK+'] | ||
# # handle_expected_actual(0.65, mean2 / mean3) | ||
# handle_expected_actual(1.265, mean2 / mean3) | ||
compare(values3, values2, expected_fold=1.265) | ||
|
||
df = access.counts([KRT['14'], KRT['7']]) | ||
fractions = df['KRT14+ CK+ and KRT7+ CK+'] / df['all cells'] | ||
mean0 = float(mean(fractions)) | ||
print(mean0) | ||
|
||
df = access.counts([KRT['14'], KRT['5']]) | ||
fractions = df['KRT14+ CK+ and KRT5+ CK+'] / df['all cells'] | ||
mean0 = float(mean(fractions)) | ||
print(mean0) | ||
|
||
df = access.counts([KRT['14'], KRT['19']]) | ||
fractions = df['KRT14+ CK+'] / df['KRT19+ CK+'] | ||
fractions = fractions[fractions != inf] | ||
fractions1 = fractions[df['cohort'] == '1'] | ||
fractions2 = fractions[df['cohort'] == '2'] | ||
fractions3 = fractions[df['cohort'] == '3'] | ||
compare(fractions3, fractions2, expected_fold=111.32, show_pvalue=True) | ||
compare(fractions1, fractions2, expected_fold=11.39, show_pvalue=True) | ||
|
||
|
||
study = 'Breast cancer IMC' | ||
if len(sys.argv) == 1: | ||
access = DataAccessor(study) | ||
else: | ||
access = DataAccessor(study, host=sys.argv[1]) | ||
|
||
|
||
KRT = { | ||
'5': {'positive_markers': ['KRT5', 'CK'], 'negative_markers': []}, | ||
'7': {'positive_markers': ['KRT7', 'CK'], 'negative_markers': []}, | ||
'14': {'positive_markers': ['KRT14', 'CK'], 'negative_markers': []}, | ||
'19': {'positive_markers': ['KRT19', 'CK'], 'negative_markers': []}, | ||
} | ||
|
||
df = access.proximity([KRT['14'], KRT['7']]) | ||
values1 = df[df['cohort'] == '1']['proximity, KRT14+ CK+ and KRT7+ CK+'] | ||
values2 = df[df['cohort'] == '2']['proximity, KRT14+ CK+ and KRT7+ CK+'] | ||
mean1 = mean(values1) | ||
mean2 = mean(values2) | ||
print((mean2, mean1, mean2 / mean1)) | ||
|
||
df = access.proximity([KRT['14'], KRT['5']]) | ||
values2 = df[df['cohort'] == '2']['proximity, KRT14+ CK+ and KRT5+ CK+'] | ||
values3 = df[df['cohort'] == '3']['proximity, KRT14+ CK+ and KRT5+ CK+'] | ||
mean2 = mean(values2) | ||
mean3 = mean(values3) | ||
print((mean2, mean3, mean2 / mean3)) | ||
|
||
df = access.counts([KRT['14'], KRT['7']]) | ||
fractions = df['KRT14+ CK+ and KRT7+ CK+'] / df['all cells'] | ||
print(mean(fractions)) | ||
|
||
|
||
df = access.counts([KRT['14'], KRT['5']]) | ||
fractions = df['KRT14+ CK+ and KRT5+ CK+'] / df['all cells'] | ||
print(mean(fractions)) | ||
|
||
df = access.counts([KRT['14'], KRT['19']]) | ||
fractions = df['KRT14+ CK+'] / df['KRT19+ CK+'] | ||
fractions = fractions[fractions != inf] | ||
fractions1 = fractions[df['cohort'] == '1'] | ||
fractions2 = fractions[df['cohort'] == '2'] | ||
fractions3 = fractions[df['cohort'] == '3'] | ||
mean1 = mean(fractions1) | ||
mean2 = mean(fractions2) | ||
mean3 = mean(fractions3) | ||
print((mean2, mean3, mean2 / mean3)) | ||
print((mean2, mean1, mean2 / mean1)) | ||
if __name__=='__main__': | ||
host: str | None | ||
if len(sys.argv) == 2: | ||
host = sys.argv[1] | ||
else: | ||
host = get_default_host(None) | ||
if host is None: | ||
raise RuntimeError('Could not determine API server.') | ||
test(get_default_host(None)) |
Oops, something went wrong.