SURE-tools 2.0.5__py3-none-any.whl → 2.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of SURE-tools might be problematic. Click here for more details.

SURE/SURE.py CHANGED
@@ -11,7 +11,7 @@ from torch.distributions import constraints
11
11
  from torch.distributions.transforms import SoftmaxTransform
12
12
 
13
13
  from .utils.custom_mlp import MLP, Exp
14
- from .utils.utils import CustomDataset, CustomDataset3, CustomDataset4, tensor_to_numpy, convert_to_tensor
14
+ from .utils.utils import CustomDataset, CustomDataset2, CustomDataset4, tensor_to_numpy, convert_to_tensor
15
15
 
16
16
 
17
17
  import os
@@ -814,11 +814,13 @@ class SURE(nn.Module):
814
814
  return A
815
815
 
816
816
  def _cell_move(self, xs, factor_idx, perturb):
817
- zns = self.encoder_zn(xs)
817
+ zns,_ = self.encoder_zn(xs)
818
818
  if type(factor_idx) == str:
819
819
  factor_idx = np.where(self.cell_factor_names==factor_idx)
820
820
 
821
821
  if perturb.ndim==2:
822
+ print(factor_idx)
823
+ print(type(perturb))
822
824
  ms = self.cell_factor_effect[factor_idx]([zns, perturb])
823
825
  else:
824
826
  ms = self.cell_factor_effect[factor_idx]([zns, perturb.reshape(-1,1)])
@@ -836,19 +838,30 @@ class SURE(nn.Module):
836
838
  """
837
839
  xs = self.preprocess(xs)
838
840
  xs = convert_to_tensor(xs, device=self.get_device())
839
- dataset = CustomDataset(xs)
841
+ ps = convert_to_tensor(perturb, device=self.get_device())
842
+ dataset = CustomDataset2(xs,ps)
840
843
  dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=False)
841
844
 
842
845
  Z = []
843
846
  with tqdm(total=len(dataloader), desc='', unit='batch') as pbar:
844
- for X_batch, _ in dataloader:
845
- zns = self._cell_move(X_batch, factor_idx, perturb)
847
+ for X_batch, P_batch, _ in dataloader:
848
+ zns = self._cell_move(X_batch, factor_idx, P_batch)
846
849
  Z.append(tensor_to_numpy(zns))
847
850
  pbar.update(1)
848
851
 
849
852
  Z = np.concatenate(Z)
850
853
  return Z
851
854
 
855
+ def get_metacell_move(self, factor_idx, perturb):
856
+ zs = self._get_codebook()
857
+ ps = convert_to_tensor(perturb, device=self.get_device())
858
+
859
+ if type(factor_idx) == str:
860
+ factor_idx = np.where(self.cell_factor_names==factor_idx)
861
+
862
+ ms = self.cell_factor_effect[factor_idx]([zs,ps])
863
+ return tensor_to_numpy(ms)
864
+
852
865
  def preprocess(self, xs, threshold=0):
853
866
  if self.loss_func == 'bernoulli':
854
867
  ad = sc.AnnData(xs)
SURE/flow/plot_quiver.py CHANGED
@@ -32,7 +32,7 @@ def plot_quiver(z_points, delta_z, method='umap', figsize=(6,4), dpi=200):
32
32
  sc.pp.neighbors(ad)
33
33
  sc.tl.umap(ad)
34
34
  z_2d = ad[:z_points.shape[0]].obsm['X_umap']
35
- delta_z_2d = ad[z_points.shape[0]:] - z_2d
35
+ delta_z_2d = ad[z_points.shape[0]:].obsm['X_umap'] - z_2d
36
36
  dim_names = ['UMAP1', 'UMAP2']
37
37
 
38
38
  # 绘制quiver图
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SURE-tools
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: Succinct Representation of Single Cells
5
5
  Home-page: https://github.com/ZengFLab/SURE
6
6
  Author: Feng Zeng
@@ -1,4 +1,4 @@
1
- SURE/SURE.py,sha256=0brySH3zXtYAW8eff5BzL1vYq_nmR82wpEPeH-FcLE8,50527
1
+ SURE/SURE.py,sha256=08gZ70PUNeTr5XY5BpaH3H4tQ9Hq3QjKXKDy14c97us,51051
2
2
  SURE/SURE2.py,sha256=8wlnMwb1xuf9QUksNkWdWx5ZWq-xIy9NLx8RdUnE82o,48501
3
3
  SURE/__init__.py,sha256=mxdLoWa2fPEM4-WkJetMfcecpzqJ8YsM4lOoKHSLTrU,207
4
4
  SURE/assembly/__init__.py,sha256=jxZLURXKPzXe21LhrZ09LgZr33iqdjlQy4oSEj5gR2Q,172
@@ -9,15 +9,15 @@ SURE/atac/utils.py,sha256=m4NYwpy9O5T1pXTzgCOCcmlwrC6GTi-cQ5sm2wZu2O8,4354
9
9
  SURE/codebook/__init__.py,sha256=2T5gjp8JIaBayrXAnOJYSebQHsWprOs87difpR1OPNw,243
10
10
  SURE/codebook/codebook.py,sha256=ZlN6gRX9Gj2D2u3P5KeOsbZri0MoMAiJo9lNeL-MK-I,17117
11
11
  SURE/flow/__init__.py,sha256=uiF9eyo6sz5qw7fRFiKipaXHboAakeIqVWo8yjkq0B0,36
12
- SURE/flow/plot_quiver.py,sha256=XRH1POyn2H7qJ_gSqo39YmjOR_Dn8a_9M_s-dnHJLlo,1850
12
+ SURE/flow/plot_quiver.py,sha256=spcPC0BDpvC-FBk9XIu6rcJI64bS-U-IVmmKLYHHXgs,1865
13
13
  SURE/flow/quiver.py,sha256=_euFqSaRrDoZ_oOabOx20LOoUTJ__XPhLW-vzLNQfAo,1859
14
14
  SURE/utils/__init__.py,sha256=Htqv4KqVKcRiaaTBsR-6yZ4LSlbhbzutjNKXGD9-uds,660
15
15
  SURE/utils/custom_mlp.py,sha256=07TYX1HgxfEjb_3i5MpiZfNhOhx3dKntuwGkrpteWiM,7036
16
16
  SURE/utils/queue.py,sha256=E_5PA5EWcBoGAZj8BkKQnkCK0p4C-4-xcTPqdIXaPXU,1892
17
17
  SURE/utils/utils.py,sha256=IUHjDDtYaAYllCWsZyIzqQwaLul6fJRvHRH4vIYcR-c,8462
18
- sure_tools-2.0.5.dist-info/licenses/LICENSE,sha256=TFHKwmrAViXQbSX5W-NDItkWFjm45HWOeUniDrqmnu0,1065
19
- sure_tools-2.0.5.dist-info/METADATA,sha256=DSDQeffAyyRgBfKxdWTsk7DBd71C3zGdnMlKY4bz1_g,2650
20
- sure_tools-2.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
- sure_tools-2.0.5.dist-info/entry_points.txt,sha256=u12payZYgCBy5FCwRHP6AlSQhKCiWSEDwj68r1DVdn8,40
22
- sure_tools-2.0.5.dist-info/top_level.txt,sha256=BtFTebdiJeqra4r6mm-uEtwVRFLZ_IjYsQ7OnalrOvY,5
23
- sure_tools-2.0.5.dist-info/RECORD,,
18
+ sure_tools-2.0.7.dist-info/licenses/LICENSE,sha256=TFHKwmrAViXQbSX5W-NDItkWFjm45HWOeUniDrqmnu0,1065
19
+ sure_tools-2.0.7.dist-info/METADATA,sha256=qqfn9Ml8x5SDWfEB-WIaMCJCmHElRi65j99-v6uBwms,2650
20
+ sure_tools-2.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
+ sure_tools-2.0.7.dist-info/entry_points.txt,sha256=u12payZYgCBy5FCwRHP6AlSQhKCiWSEDwj68r1DVdn8,40
22
+ sure_tools-2.0.7.dist-info/top_level.txt,sha256=BtFTebdiJeqra4r6mm-uEtwVRFLZ_IjYsQ7OnalrOvY,5
23
+ sure_tools-2.0.7.dist-info/RECORD,,