Skip to content

Commit

Permalink
Renamed repository (#165)
Browse files Browse the repository at this point in the history
* change package name

* renamed references

* updated notebooks

* update travis command

* removed remaining reference to segmentation

* pep8 from copy/paste

* reordered test functions, removed old code

* more sneaky pep8

* typo
  • Loading branch information
ngreenwald committed Aug 14, 2020
1 parent 66cb4d4 commit 9b83046
Show file tree
Hide file tree
Showing 47 changed files with 968 additions and 2,699 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

# command to run tests
script:
- python -m pytest --cov=segmentation --pep8 segmentation
- python -m pytest --cov=ark --pep8 ark

after_success:
- coveralls
- coveralls
File renamed without changes.
Empty file added ark/analysis/__init__.py
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import numpy as np
import string
import random as rand
from segmentation.utils import dimensionality_reduction
import importlib
import tempfile
import os

importlib.reload(dimensionality_reduction)

from ark.analysis import dimensionality_reduction


def test_dimensionality_reduction():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import pandas as pd
import xarray as xr
import numpy as np
from segmentation.utils import spatial_analysis_utils
import importlib
importlib.reload(spatial_analysis_utils)
from ark.utils import spatial_analysis_utils


def calculate_channel_spatial_enrichment(dist_matrices_dict, marker_thresholds, all_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
import pandas as pd
import xarray as xr
import random
from segmentation.utils import spatial_analysis
from segmentation.utils import spatial_analysis_utils
from segmentation.utils import synthetic_spatial_datagen
import importlib
importlib.reload(spatial_analysis)

from ark.analysis import spatial_analysis
from ark.utils import synthetic_spatial_datagen

def make_threshold_mat():

def _make_threshold_mat():
thresh = pd.DataFrame(np.zeros((20, 2)))
thresh.iloc[:, 1] = .5
thresh.iloc[:, 0] = np.arange(20) + 2
return thresh


def make_distance_matrix(enrichment_type, dist_lim):
def _make_distance_matrix(enrichment_type, dist_lim):
# Make a distance matrix for no enrichment, positive enrichment, and negative enrichment

if enrichment_type == "none":
Expand Down Expand Up @@ -59,7 +57,7 @@ def make_distance_matrix(enrichment_type, dist_lim):
return dist_mat_neg


def make_expression_matrix(enrichment_type):
def _make_expression_matrix(enrichment_type):
# Create the expression matrix with cell labels and patient labels for no enrichment,
# positive enrichment, and negative enrichment.

Expand Down Expand Up @@ -189,11 +187,11 @@ def test_calculate_channel_spatial_enrichment():
"perimeter", "SampleID", "FlowSOM_ID", "cell_type"]

# Test z and p values
marker_thresholds = make_threshold_mat()
marker_thresholds = _make_threshold_mat()

# Positive enrichment with direct matrix initialization
all_data_pos = make_expression_matrix(enrichment_type="positive")
dist_mat_pos_direct = make_distance_matrix(enrichment_type="positive", dist_lim=dist_lim)
all_data_pos = _make_expression_matrix(enrichment_type="positive")
dist_mat_pos_direct = _make_distance_matrix(enrichment_type="positive", dist_lim=dist_lim)

_, stats_pos = \
spatial_analysis.calculate_channel_spatial_enrichment(
Expand All @@ -213,8 +211,8 @@ def test_calculate_channel_spatial_enrichment():
assert stats_pos.loc["Point9", "z", 3, 2] > 0

# Negative enrichment with direct matrix initialization
all_data_neg = make_expression_matrix("negative")
dist_mat_neg_direct = make_distance_matrix("negative", dist_lim=dist_lim)
all_data_neg = _make_expression_matrix("negative")
dist_mat_neg_direct = _make_distance_matrix("negative", dist_lim=dist_lim)

_, stats_neg = \
spatial_analysis.calculate_channel_spatial_enrichment(
Expand All @@ -234,8 +232,8 @@ def test_calculate_channel_spatial_enrichment():
assert stats_neg.loc["Point9", "z", 3, 2] < 0

# No enrichment
all_data_no_enrich = make_expression_matrix("none")
dist_mat_no_enrich = make_distance_matrix("none", dist_lim=dist_lim)
all_data_no_enrich = _make_expression_matrix("none")
dist_mat_no_enrich = _make_distance_matrix("none", dist_lim=dist_lim)

_, stats_no_enrich = \
spatial_analysis.calculate_channel_spatial_enrichment(
Expand Down Expand Up @@ -264,8 +262,8 @@ def test_calculate_cluster_spatial_enrichment():
"perimeter", "SampleID", "FlowSOM_ID", "cell_type"]

# Positive enrichment with direct matrix initialization
all_data_pos = make_expression_matrix(enrichment_type="positive")
dist_mat_pos_direct = make_distance_matrix(enrichment_type="positive", dist_lim=dist_lim)
all_data_pos = _make_expression_matrix(enrichment_type="positive")
dist_mat_pos_direct = _make_distance_matrix(enrichment_type="positive", dist_lim=dist_lim)

_, stats_pos = \
spatial_analysis.calculate_cluster_spatial_enrichment(
Expand All @@ -283,8 +281,8 @@ def test_calculate_cluster_spatial_enrichment():
assert stats_pos.loc["Point9", "z", "Pheno2", "Pheno1"] > 0

# Negative enrichment with direct matrix initialization
all_data_neg = make_expression_matrix("negative")
dist_mat_neg_direct = make_distance_matrix(enrichment_type="negative", dist_lim=dist_lim)
all_data_neg = _make_expression_matrix("negative")
dist_mat_neg_direct = _make_distance_matrix(enrichment_type="negative", dist_lim=dist_lim)

_, stats_neg = \
spatial_analysis.calculate_cluster_spatial_enrichment(
Expand All @@ -302,8 +300,8 @@ def test_calculate_cluster_spatial_enrichment():
assert stats_neg.loc["Point9", "z", "Pheno2", "Pheno1"] < 0

# No enrichment
all_data_no_enrich = make_expression_matrix("none")
dist_mat_no_enrich = make_distance_matrix("none", dist_lim=dist_lim)
all_data_no_enrich = _make_expression_matrix("none")
dist_mat_no_enrich = _make_distance_matrix("none", dist_lim=dist_lim)

_, stats_no_enrich = \
spatial_analysis.calculate_cluster_spatial_enrichment(
Expand All @@ -322,8 +320,8 @@ def test_calculate_cluster_spatial_enrichment():

def test_create_neighborhood_matrix():
# get positive expression and distance matrices
all_data_pos = make_expression_matrix("positive")
dist_mat_pos = make_distance_matrix("positive", dist_lim=51)
all_data_pos = _make_expression_matrix("positive")
dist_mat_pos = _make_distance_matrix("positive", dist_lim=51)

counts, freqs = spatial_analysis.create_neighborhood_matrix(all_data_pos, dist_mat_pos, distlim=51)

Expand Down
2 changes: 0 additions & 2 deletions segmentation/utils/visualize.py → ark/analysis/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import matplotlib.pyplot as plt
import seaborn as sns

from matplotlib.patches import Ellipse


def visualize_z_scores(z, pheno_titles):
"""Plots the z scores between all phenotypes as a clustermap.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import numpy as np
import random
from segmentation.utils import visualize
import importlib
import pandas as pd
import string
import os.path
from os import path

importlib.reload(visualize)
from ark.analysis import visualize


def test_visualize_z_scores():
Expand Down
Empty file added ark/segmentation/__init__.py
Empty file.
Loading

0 comments on commit 9b83046

Please sign in to comment.