@@ -77,8 +77,8 @@ def cells_niche_colors(CTs, niche_colors, niche_dict):
7777 niche_df ['niche' ]= niche_colors .index [0 ]
7878 niche_df ['color' ]= niche_colors [0 ]
7979 for key in list (niche_dict .keys ()):
80- niche_df [ 'niche' ][[ c in niche_dict [key ] for c in niche_df .cell ]]= key
81- niche_df [ 'color' ][ niche_df ['niche' ]== key ]= niche_colors [key ]
80+ niche_df . loc [[ c in niche_dict [key ] for c in niche_df .cell ], 'niche' ]= key
81+ niche_df . loc [ niche_df ['niche' ]== key , 'color' ]= niche_colors [key ]
8282 niche_df .index = niche_df .cell
8383 niche_df .niche = niche_df .niche .astype ('category' )
8484 return niche_df
@@ -155,7 +155,7 @@ def PIC_BGdoubletsOEratios(adata_singlets, annot_col):
155155 ## Get random singlets pairs
156156 pairNums = [i for i in range (int (np .round (adata_singlets .obs .shape [0 ]// 2 ))) for _ in range (2 )]
157157 pairNumsIdx = random .sample (list (adata_singlets .obs .index ), len (pairNums ))
158- rdf .pair [pairNumsIdx ]= pairNums
158+ rdf .loc [pairNumsIdx , 'pair' ]= pairNums
159159
160160 pairCounts = [rdf .annot [rdf .pair == i ][0 ]+ '-' + rdf .annot [rdf .pair == i ][1 ] for i in rdf .pair .value_counts ().index [rdf .pair .value_counts ()== 2 ]]
161161
@@ -331,10 +331,10 @@ def get_pairCatDFdir(niches_df):
331331
332332 pairCatDFdir ['niche_pairs' ]= ''
333333 for clust in np .sort (niches_df .niche .unique ()):
334- pairCatDFdir [ 'niche_pairs' ][[ cellCatContained (pair = p , cellCat = niches_df .cell [niches_df .niche == clust ]) for p in pairCatDFdir .cell_pairs ]]= clust + '->' + clust
334+ pairCatDFdir . loc [[ cellCatContained (pair = p , cellCat = niches_df .cell [niches_df .niche == clust ]) for p in pairCatDFdir .cell_pairs ], 'niche_pairs' ]= clust + '->' + clust
335335
336336 for comb in list (itertools .permutations (list (niches_df .niche .unique ().sort_values ()), 2 )):
337- pairCatDFdir [ 'niche_pairs' ][[ (p .split ('->' )[0 ] in niches_df .cell [niches_df .niche == comb [0 ]]) & (p .split ('->' )[1 ] in niches_df .cell [niches_df .niche == comb [1 ]]) for p in pairCatDFdir .cell_pairs ]]= comb [0 ]+ '->' + comb [1 ]
337+ pairCatDFdir . loc [[ (p .split ('->' )[0 ] in niches_df .cell [niches_df .niche == comb [0 ]]) & (p .split ('->' )[1 ] in niches_df .cell [niches_df .niche == comb [1 ]]) for p in pairCatDFdir .cell_pairs ], 'niche_pairs' ]= comb [0 ]+ '->' + comb [1 ]
338338
339339 return pairCatDFdir
340340#%%
@@ -385,10 +385,10 @@ def getColocFilter(pairCatDF, adj, oneCTints):
385385 colocFilt ['filter' ]= 0
386386
387387 for i in pairCatDF .cell_pairs :
388- colocFilt [ 'filter' ][ i ]= adj .loc [i .split ('->' )[1 ],i .split ('->' )[0 ]]
388+ colocFilt . loc [ i , 'filter' ]= adj .loc [i .split ('->' )[1 ],i .split ('->' )[0 ]]
389389
390- colocFilt [ 'filter' ][ oneCTints ]= 1
391- colocFilt [ 'filter' ][ colocFilt ['filter' ]> 0 ]= 1
390+ colocFilt . loc [ oneCTints , 'filter' ]= 1
391+ colocFilt . loc [ colocFilt ['filter' ]> 0 , 'filter' ]= 1
392392 colocFilt = pd .DataFrame (colocFilt ['filter' ], index = colocFilt .index , columns = ['filter' ])
393393 return colocFilt
394394
0 commit comments