File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66from scipy .stats import gmean
77from sklearn .decomposition import PCA
88from sklearn .linear_model import LinearRegression
9- from sklearn .preprocessing import scale
109from tqdm import tqdm
1110
1211
@@ -147,7 +146,8 @@ def rise_pca_r2x(X: anndata.AnnData, ranks):
147146 r2x_rise [index ] = R2X
148147
149148 # Mean center because this is done within RISE
150- XX = scale (XX .todense (), with_mean = True , with_std = False )
149+ XX = XX .toarray ()
150+ XX = XX - np .mean (XX , axis = 0 )
151151
152152 pca = PCA (n_components = ranks [- 1 ])
153153 pca .fit (XX )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def gateThomsonCells(X) -> npt.ArrayLike:
1919 """Manually gates cell types for Thomson PaCMAP"""
2020 cellTypeDF = pd .read_csv ("analysis/data/Thomson/ThomsonCellTypes.csv" , index_col = 0 )
2121 cellTypeDF .index .name = "cell_barcode"
22- X .obs = X .obs .join (cellTypeDF , on = "cell_barcode" , how = "inner" )
22+ X .obs = X .obs .join (cellTypeDF , how = "inner" )
2323
2424 X .obs ["Cell Type" ] = X .obs ["Cell Type" ].values .astype (str )
2525 X .obs ["Cell Type2" ] = X .obs ["Cell Type2" ].values .astype (str )
Original file line number Diff line number Diff line change @@ -21,25 +21,25 @@ def import_thomson() -> anndata.AnnData:
2121
2222 X .obs = pd .DataFrame (
2323 {
24- "cell_barcode" : metafile ["cell_barcode" ],
2524 "Condition" : pd .Categorical (metafile ["sample_id" ]),
26- }
25+ },
26+ index = metafile ["cell_barcode" ]
2727 )
28+ X .obs .index .name = "cell_barcode"
2829
2930 doubletDF = pd .read_csv ("analysis/data/Thomson/ThomsonDoublets.csv" , index_col = 0 )
3031 doubletDF .index .name = "cell_barcode"
31- X .obs = X .obs .join (doubletDF , on = "cell_barcode" , how = "inner" )
32+ X .obs = X .obs .join (doubletDF , how = "inner" )
3233
3334 singlet_indices = X .obs .loc [X .obs ["doublet" ] == 0 ].index .values
34- X .obs = X .obs .reset_index (drop = True )
3535 X = X [singlet_indices , :]
3636
37- X .obs = X .obs .set_index ("cell_barcode" )
3837 gateThomsonCells (X )
3938
4039 return prepare_dataset (X , "Condition" , geneThreshold = 0.01 )
4140
4241
42+
4343def import_lupus (geneThreshold : float = 0.1 ) -> anndata .AnnData :
4444 """Import Lupus PBMC dataset.
4545
Original file line number Diff line number Diff line change 11[project ]
22name = " RISE"
3- version = " 0 .1.0"
3+ version = " 1 .1.0"
44description = " Single cell analysis across conditions using PARAFAC2."
55authors = [{name = " Andrew Ramirez" }, {name = " Aaron Meyer" , email = " git@asmlab.org" }]
66license = " MIT"
You can’t perform that action at this time.
0 commit comments