def compute_bulk_smushing(self):
"""Get average signal from each plate ('bulk') and find 2d embedding"""
grouped = self.genes.groupby(self.cell_metadata[self.SAMPLE_MAPPING])
if os.path.exists(self.bulk_smushed_cache_file):
smushed = pd.read_csv(self.bulk_smushed_cache_file, names=[0, 1],
header=0, index_col=0)
# if the set of plates hasn't changed, return the cached version
if set(grouped.groups) == set(smushed.index):
return smushed
# if the cache was missing or invalid, compute a new projection
medians = grouped.median()
smusher = TSNE(random_state=0, perplexity=10, metric='cosine')
smushed = pd.DataFrame(smusher.fit_transform(medians),
index=medians.index)
smushed.to_csv(self.bulk_smushed_cache_file)
return smushed
评论列表
文章目录