Skip to content

Commit

Permalink
fix cell label assignment issue in batch removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrovatin authored Oct 1, 2023
1 parent 0608477 commit bdb646c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scgen/_scgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def batch_removal(self, adata: Optional[AnnData] = None) -> AnnData:
corrected = AnnData(
self.module.generative(torch.Tensor(all_shared_ann.X))["px"]
.cpu()
.detach()
.numpy(),
obs=all_shared_ann.obs,
)
Expand All @@ -283,7 +284,7 @@ def batch_removal(self, adata: Optional[AnnData] = None) -> AnnData:
adata_raw = AnnData(X=adata.raw.X, var=adata.raw.var)
adata_raw.obs_names = adata.obs_names
corrected.raw = adata_raw
corrected.obsm["latent"] = all_shared_ann.X
corrected.obsm["latent"] = all_shared_ann[corrected.obs_names,:].X
corrected.obsm["corrected_latent"] = self.get_latent_representation(
corrected
)
Expand All @@ -303,6 +304,7 @@ def batch_removal(self, adata: Optional[AnnData] = None) -> AnnData:
corrected = AnnData(
self.module.generative(torch.Tensor(all_corrected_data.X))["px"]
.cpu()
.detach()
.numpy(),
obs=all_corrected_data.obs,
)
Expand All @@ -312,7 +314,7 @@ def batch_removal(self, adata: Optional[AnnData] = None) -> AnnData:
adata_raw = AnnData(X=adata.raw.X, var=adata.raw.var)
adata_raw.obs_names = adata.obs_names
corrected.raw = adata_raw
corrected.obsm["latent"] = all_corrected_data.X
corrected.obsm["latent"] = all_corrected_data[corrected.obs_names,:].X
corrected.obsm["corrected_latent"] = self.get_latent_representation(
corrected
)
Expand Down

0 comments on commit bdb646c

Please sign in to comment.