def load_palantir_data(smoothed=False): fn = '../../data/external/Palantir/human_cd34_bm_rep1.h5ad' an = anndata.read_h5ad(fn) genes = an.var_names cells = an.obs_names if not smoothed: counts = singlet.CountsTable( data=an.raw.X.todense().T, index=genes, columns=cells, ) else: counts = singlet.CountsTable( data=an.obsm['MAGIC_imputed_data'].T, index=genes, columns=cells, ) ss = singlet.SampleSheet(an.obs) ss['tsne_1'] = an.obsm['tsne'][:, 0] ss['tsne_2'] = an.obsm['tsne'][:, 1] ss['clusters'] = ss['clusters'].astype(str) ds = singlet.Dataset( counts_table=counts, samplesheet=ss, ) return ds
def load_palantir_data(smoothed=False): fn = '../../data/external/Palantir/human_cd34_bm_rep1.h5ad' an = anndata.read_h5ad(fn) genes = an.var_names cells = an.obs_names if not smoothed: counts = singlet.CountsTable( data=an.raw.X.todense().T, index=genes, columns=cells, ) else: counts = singlet.CountsTable( data=an.obsm['MAGIC_imputed_data'].T, index=genes, columns=cells, ) ss = singlet.SampleSheet(an.obs) ss['tsne_1'] = an.obsm['tsne'][:, 0] ss['tsne_2'] = an.obsm['tsne'][:, 1] ss['clusters'] = ss['clusters'].astype(str) ds = singlet.Dataset( counts_table=counts, samplesheet=ss, ) ds.samplesheet['Cell Subtype'] = ds.samplesheet['clusters'].replace({ '0': 'HSC', '1': 'HSC', '2': 'Ery-precursor', '3': 'Mono', '4': 'Mono-precursor', '5': 'CLP', '6': 'Mono', '7': 'pDC', '8': 'Ery', '9': 'Mega', }) return ds
import anndata if __name__ == '__main__': fn = '../../data/external/Palantir/human_cd34_bm_rep1.h5ad' an = anndata.read_h5ad(fn) genes = an.var_names cells = an.obs_names counts = singlet.CountsTable( data=an.X.T, index=genes, columns=cells, ) ss = singlet.SampleSheet(an.obs) ss['tsne_1'] = an.obsm['tsne'][:, 0] ss['tsne_2'] = an.obsm['tsne'][:, 1] ss['clusters'] = ss['clusters'].astype(str) ds = singlet.Dataset( counts_table=counts, samplesheet=ss, ) print('Get MAGIC smoothed data') counts = singlet.CountsTable( data=an.obsm['MAGIC_imputed_data'].T, index=genes, columns=cells, )