text_plain_output_1.png
import umap
reducer = umap.UMAP(random_state=42)
r = reducer.fit_transform(df)
dict_reds = {}
dict_reds['umap'] = r
n_x_subplots = 2
c = 0
str_data_inf = 'CITEseq2302'
l = ['CD45RA', 'CD45RO', 'PTPRC', 'CD53', 'MALAT1', 'NEAT1', 'CD3', 'CD4', 'CD69']
for gene in l[:40]:
    if gene in df.columns:
        v4color = df[gene]
    elif gene in df_Y.columns:
        v4color = df_Y[gene]
    else:
        continue
    v4color = np.clip(v4color, np.percentile(v4color, 5), np.percentile(v4color, 95))
    if c % n_x_subplots == 0:
        if c > 0:
            plt.show()
        fig = plt.figure(figsize=(20, 4))
        c = 0
        plt.suptitle(' UMAP ' + str_data_inf + ' n_samples=' + str(len(df)), fontsize=12)
    c += 1
    fig.add_subplot(1, n_x_subplots, c)
    sns.scatterplot(x=r[:, 0], y=r[:, 1], hue=v4color, palette='rainbow')