Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occurred after Integration of batches. #97

Open
zhrmxxs opened this issue Sep 29, 2024 · 1 comment
Open

Error occurred after Integration of batches. #97

zhrmxxs opened this issue Sep 29, 2024 · 1 comment

Comments

@zhrmxxs
Copy link

zhrmxxs commented Sep 29, 2024

I encountered a strange situation, after the integration of batches., the cNMF result file cNMF.usages.k_28.dt_2_0.consensus.txt is blank. Other result files, such as cNMF.gene_spectra_score.k_28.dt_2_0.txt, are normal, and do not experience any errors during the process.
In addition, when the integration of batches is not performed, the resulting files are all normal.
Here is the code when executing off batch and not executing.
My data consists of multiple samples, which should be executed in integration of batche. May I ask how to solve the above situation?

`

Integration of batches.

import os
import pandas as pd
import numpy as np
import pickle
from scipy.io import mmread
import scipy.sparse as sp
import matplotlib.pyplot as plt
from IPython.display import Image
import scanpy as sc
from cnmf import cNMF, Preprocess
np.random.seed(14)
##############
adata = sc.read_h5ad("merge/counts.h5ad")
adata.var_names_make_unique()
###################
p = Preprocess(random_seed=14)
(adata_c, adata_tpm, hvgs) = p.preprocess_for_cnmf(adata, harmony_vars=['sample'], n_top_rna_genes = 2000, librarysize_targetsum= 1e6, save_output_base='./batchcorrect_merge')
##############
output_dir = "batchcorrect_merge"
run_name = 'merge_cNMF'
##############
cnmf_obj = cNMF(output_dir=output_dir, name=run_name)
cnmf_obj.prepare(counts_fn='batchcorrect_merge.Corrected.HVG.Varnorm.h5ad' ,
tpm_fn='batchcorrect_merge.TP10K.h5ad',
genes_file='batchcorrect_merge.Corrected.HVGs.txt',
components=np.arange(2,31), n_iter=200, seed=14, num_highvar_genes=2000)
cnmf_obj.factorize(worker_i=0, total_workers=1)
cnmf_obj.combine()
cnmf_obj.k_selection_plot(close_fig=False)
##############
selected_K = 28
density_threshold = 2
cnmf_obj.consensus(k= selected_K, density_threshold = density_threshold, show_clustering=True, close_clustergram_fig=False)

#######################################################################################
#######################################################################################
#######################################################################################

No integration of batches.

import os
import pandas as pd
import numpy as np
import pickle
from scipy.io import mmread
import scipy.sparse as sp
import matplotlib.pyplot as plt
from IPython.display import Image
import scanpy as sc
from cnmf import cNMF, Preprocess
np.random.seed(14)
##############
output_dir = "'merge/"
run_name = 'merge_cNMF'
count_adat_fn = 'merge/counts.h5ad'
##############
cnmf_obj = cNMF(output_dir=output_dir, name=run_name)
cnmf_obj.prepare(counts_fn=count_adat_fn, components=np.arange(2,31), n_iter=200, seed=14, num_highvar_genes=2000)
cnmf_obj.factorize(worker_i=0, total_workers=1)
cnmf_obj.combine()
cnmf_obj.k_selection_plot(close_fig=False)
##############
selected_K = 28
density_threshold = 2
cnmf_obj.consensus(k= selected_K, density_threshold = density_threshold, show_clustering=True, close_clustergram_fig=False)`

@dylkot
Copy link
Owner

dylkot commented Sep 29, 2024

Hi @zhrmxxs, that is very odd. The cNMF.usages.k_28.dt_2_0.consensus.txt file is more of an intermediate output file so I'm surprised it is blank. I'll have to look into that a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants