@@ -1371,7 +1371,7 @@ def concatenate(self, *adatas, join='inner', batch_key='batch', batch_categories
1371
1371
logg .info (
1372
1372
'Making variable names unique for controlled concatenation.' )
1373
1373
printed_info = True
1374
-
1374
+
1375
1375
mergers = dict (inner = set .intersection , outer = set .union )
1376
1376
var_names = pd .Index (reduce (mergers [join ], (set (ad .var_names ) for ad in all_adatas )))
1377
1377
@@ -1402,6 +1402,9 @@ def concatenate(self, *adatas, join='inner', batch_key='batch', batch_categories
1402
1402
# obs
1403
1403
obs = ad .obs .copy ()
1404
1404
obs [batch_key ] = pd .Categorical (ad .n_obs * [categories [i ]], categories )
1405
+ if (is_string_dtype (all_adatas [0 ].obs .index ) and not
1406
+ is_string_dtype (ad .obs .index )):
1407
+ obs .index = obs .index .astype (str )
1405
1408
if index_unique is not None :
1406
1409
if not is_string_dtype (ad .obs .index ):
1407
1410
obs .index = obs .index .astype (str )
@@ -1415,7 +1418,12 @@ def concatenate(self, *adatas, join='inner', batch_key='batch', batch_categories
1415
1418
uns = all_adatas [0 ].uns
1416
1419
obsm = np .concatenate ([ad .obsm for ad in all_adatas ])
1417
1420
varm = self .varm # TODO
1418
- return AnnData (X , obs , var , uns , obsm , None , filename = self .filename )
1421
+
1422
+ new_adata = AnnData (X , obs , var , uns , obsm , None , filename = self .filename )
1423
+ if not obs .index .is_unique :
1424
+ logg .info (
1425
+ 'Or pass `index_unique!=None` to `.concatenate`.' )
1426
+ return new_adata
1419
1427
1420
1428
def var_names_make_unique (self , join = '-' ):
1421
1429
self .var .index = utils .make_index_unique (self .var .index , join )
0 commit comments