Open bapoorva opened 4 years ago
Hi Bapoorva,
Sure. So this is the function from the jupyter notebook
def read_macaque(path):
"""A function to read and preprocess the macaque data"""
adata = sc.read(path)
sc.pp.filter_cells(adata, min_genes=0)
sc.pp.filter_genes(adata, min_cells=30)
adata = adata[adata.obs['n_genes'] < 2500, :]
return(adata)
and here is my output
adata = read_macaque("/Users/bapoorva/Desktop/Cardec/wt_i73t.h5ad")
print(adata)
View of AnnData object with n_obs × n_vars = 1876 × 1714
obs: 'sample', 'n_genes', 'n_genes_by_counts', 'total_counts', 'total_counts_mt', 'pct_counts_mt', 'leiden', 'cluster'
var: 'gene_ids', 'n_cells', 'mt', 'n_cells_by_counts', 'mean_counts', 'pct_dropout_by_counts', 'total_counts', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'mean', 'std'
uns: 'leiden', 'leiden_colors', 'neighbors', 'pca', 'sample_colors', 'umap'
obsm: 'X_pca', 'X_umap'
varm: 'PCs'
obsp: 'connectivities', 'distances'
Things look good so far. Can you run the following code snippet? Then, after you run it, can you show me the output of "print(adata)" and "print(obs_.shape)"
from scipy.sparse import issparse
from anndata import AnnData
from CarDEC.CarDEC_utils import convert_vector_to_encoding
batch_key = 'sample'
n_high_var = 2000
LVG = True,
normalize_samples = True
log_normalize = True,
normalize_features = True
n, p = adata.shape
sparsemode = issparse(adata.X)
if batch_key is not None:
batch = list(adata.obs[batch_key])
batch = convert_vector_to_encoding(batch)
batch = np.asarray(batch)
batch = batch.astype('float32')
else:
batch = np.ones((n,), dtype = 'float32')
norm_by_batch = False
sc.pp.filter_genes(adata, min_counts=1)
sc.pp.filter_cells(adata, min_counts=1)
count = adata.X.copy()
if normalize_samples:
out = sc.pp.normalize_total(adata, inplace = False)
obs_ = adata.obs
var_ = adata.var
adata = None
adata = AnnData(out['X'])
I got this
print(adata)
print(obs_.shape)
AnnData object with n_obs × n_vars = 0 × 0
(0, 9)
Hi,
I processed my single cell data using scanpy's preprocessing script. I have two samples - control and mutant that i merged before processing it. When I ran it through the cardec pipeline, i'm getting this error. Can you please help me out with this ?
Thanks