Skip to content
Merged
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
28 changes: 16 additions & 12 deletions src/sc3D/sc3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def read_anndata(
elif genes_of_interest == "all":
genes_of_interest = data.var_names
self.all_genes = sorted(genes_of_interest)

if 0 < len(genes_of_interest):
raw_X = self._to_dense(data.raw[:, self.all_genes].X)
self.gene_expression = dict(zip(ids, np.array(raw_X)))
Expand Down Expand Up @@ -511,7 +511,6 @@ def build_pairing(self, cs1, cs2, rebuild=False, refine=False, th_d=None):
zip(cells_cs1[pairing[0]], cells_cs2[pairing[1]])
)
except Exception as _:
print("re-doing linear sum assignment :(")
pairing = linear_sum_assignment(copy_d)
pos_ref_tmp = positions_cs1[pairing[0]]
pos_flo_tmp = positions_cs2[pairing[1]]
Expand Down Expand Up @@ -789,16 +788,21 @@ def downsample(self, spacing=10, pos_id="pos_3D"):
if 0 < len(v)
]
)

final_expr = np.array([
np.mean(
self._to_dense(self.anndata.raw[
mapping_from_removed[[cells[vi] for vi in v]]
].X),
axis=0,
)
for v in mapping if len(v) > 0
])

final_expr = np.array(
[
np.mean(
self._to_dense(
self.anndata.raw[
mapping_from_removed[[cells[vi] for vi in v]]
].X
),
axis=0,
)
for v in mapping
if len(v) > 0
]
)

nb_cells = np.array([len(v) for v in mapping if 0 < len(v)])
tissue = [
Expand Down
Loading