KrishnaswamyLab / MAGIC

MAGIC (Markov Affinity-based Graph Imputation of Cells), is a method for imputing missing values restoring structure of large biological datasets.
GNU General Public License v2.0
341 stars 97 forks source link

NaN values when computing the kernel lead to inability to find t-optimal MATLAB. #206

Open ElenaMerinoTejero opened 2 years ago

ElenaMerinoTejero commented 2 years ago

Hi,

I want to impute a data set X (9082 genes x433 cells) using MAGIC in Matlab.

When running run.MAGIC(X) it results in the following error:

Unrecognized function or variable 't_opt'. Error in compute_optimal_t (line 62) disp(['optimal t = ' num2str(t_opt)]);

When running MAGIC with a particular t imput:

[pc_imputed, U, pc] = run_magic_original(X', 'k',30,'a',10,'t',20,'npca',20).

The resulting pc_imputed is a matrix full of NaNs and P and K have some NaNs too. I think this is due to some zero values when calculating kdist and epsilon in the following manner:

[idx, kdist]=knnsearch(data_pc,data_pc,'k',k_knn,'Distance',distfun); epsilon=kdist(:,k+1);

Why are there NaNs in the pc_imputed and is there any suggestion you can give to find suitable pc_imputed for my data set?

Thanks in advance 🙏.