Skip to content
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

minor bug fix #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion novosparc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'[email protected]',
'[email protected]'
])
__version__ = '0.4.3'
__version__ = '0.4.4'

from . import plotting as pl
from . import preprocessing as pp
Expand Down
2 changes: 1 addition & 1 deletion novosparc/geometry/_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def create_target_space_from_image(image):
img_height = img.shape[0]

locations = np.array([(x, y) for x in range(img_width) for y in range(img_height)
if sum(img[y, x, :] == np.array([0, 0, 0]))])
if sum(img[y, x, :] == np.array(img.shape[2]))])

return locations

Expand Down
19 changes: 18 additions & 1 deletion novosparc/reconstruction/_reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,24 @@ def write_sdge_to_disk(sdge, num_cells, num_locations, folder):
np.savetxt(os.path.join(folder, 'sdge_' + str(num_cells) + '_cells_'
+ str(num_locations) + '_locations.txt'), sdge, fmt='%.4e')
print ('done (', round(time.time()-start_time, 2), 'seconds )')



def quantify_clusters_spatially(tissue):
"""Maps the annotated clusters obtained from the scRNA-seq analysis onto
the tissue space.

Args:
tissue: the novosparc tissue object containing the gene expression data,
the clusters annotation and the spatial reconstruction. Assumes
that the cluster annotation exists in the underlying anndata object.

Returns:
[numpy array]: An array of the cluster annotation per tissue position.
"""
clusters = tissue.dataset.obs['clusters'].to_numpy().flatten()
return np.array([np.argmax(np.array([np.median(np.array(tissue.gw[:, location][np.argwhere(clusters == cluster).flatten()]))
for cluster in np.unique(clusters)])) for location in range(len(tissue.locations))])


def find_spatial_archetypes(num_clusters, sdge):
"""Clusters the expression data and finds gene archetypes. Current
Expand Down