a function to determine statistically trait-enriched cell by permutation test.
get_sigcell_simple(
knn_sparse_mat,
seed_idx,
topseed_npscore,
permutation_times = 1000,
true_cell_significance = 0.05,
rda_output = FALSE,
out_rda = tempfile(fileext = "true_cell_df.rda"),
mycores = 1,
rw_gamma = 0.05
)
a sparse matrix used for network propagation, which indicates the adjacent matrix (m x m, where m is the cell number) of cell-to-cell network (M-kNN graph)
a logical vector indicating seed cells (TRUE) and non-seed cells (FALSE) with length of m, where m is the cell number. The length and position are corresponding to knn_sparse_mat
a numeric vector of real network propagation score
an integer describe times of permutation test for each cell
a numeric value between 0-1 indicating the significant threshold used to determine statistically trait-enriched cell
if output details of each permutation as a rda
if rda_output=T, an rda will be outputed with path and name specified
how many cores used for permutation test
gamma from randomWalk_sparse function. Keep the same with what you used in the real setting
A dataframe with two columns, the first one is seed index (the same with input), the second one is significance from permutation test. In addition, an R data is generated, which contains this dataframe and another dataframe depicting the network propagation score for each cell at each permuation.
knn_sparse_mat <- example_results$mutualknn30
mono_mat <- example_results$mono_mat
ture_cell_df <- get_sigcell_simple(knn_sparse_mat=knn_sparse_mat,
seed_idx=mono_mat$seed_idx,
topseed_npscore=mono_mat$np_score,
permutation_times=100)
#> Get started!
#> Stationary step: 92
#> Stationary Delta: 9.4301315588416e-06
#> Stationary step: 91
#> Stationary Delta: 9.34710748709427e-06
#> Stationary step: 87
#> Stationary Delta: 9.62779644152864e-06
#> Stationary step: 90
#> Stationary Delta: 9.94039715161695e-06
#> Stationary step: 86
#> Stationary Delta: 9.6555544898032e-06
#> Stationary step: 90
#> Stationary Delta: 9.80665048478311e-06
#> Stationary step: 88
#> Stationary Delta: 9.91205601703222e-06
#> Stationary step: 89
#> Stationary Delta: 9.86869139256761e-06
#> Stationary step: 90
#> Stationary Delta: 9.74499930760599e-06
#> Stationary step: 91
#> Stationary Delta: 9.63499003405415e-06
#> Stationary step: 90
#> Stationary Delta: 9.37245563139729e-06
#> Stationary step: 88
#> Stationary Delta: 9.69708556541958e-06
#> Stationary step: 89
#> Stationary Delta: 9.55680566863824e-06
#> Stationary step: 91
#> Stationary Delta: 9.67765739287315e-06
#> Stationary step: 89
#> Stationary Delta: 9.85600682719103e-06
#> Stationary step: 89
#> Stationary Delta: 9.96286175431387e-06
#> Stationary step: 84
#> Stationary Delta: 9.59106505215998e-06
#> Stationary step: 90
#> Stationary Delta: 9.86195226131598e-06
#> Stationary step: 87
#> Stationary Delta: 9.53145583752335e-06
#> Stationary step: 87
#> Stationary Delta: 9.46855820722052e-06
#> Stationary step: 88
#> Stationary Delta: 9.88190163935387e-06
#> Stationary step: 88
#> Stationary Delta: 9.58646856913211e-06
#> Stationary step: 86
#> Stationary Delta: 9.85990944919675e-06
#> Stationary step: 84
#> Stationary Delta: 9.83652245251877e-06
#> Stationary step: 90
#> Stationary Delta: 9.92682507276816e-06
#> Stationary step: 89
#> Stationary Delta: 9.54637455167222e-06
#> Stationary step: 86
#> Stationary Delta: 9.89366499091703e-06
#> Stationary step: 91
#> Stationary Delta: 9.80294566324767e-06
#> Stationary step: 89
#> Stationary Delta: 9.61595101877838e-06
#> Stationary step: 82
#> Stationary Delta: 9.6706391585629e-06
#> Stationary step: 85
#> Stationary Delta: 9.56199571809639e-06
#> Stationary step: 89
#> Stationary Delta: 9.32952827249979e-06
#> Stationary step: 88
#> Stationary Delta: 9.57424462380807e-06
#> Stationary step: 87
#> Stationary Delta: 9.49237603280194e-06
#> Stationary step: 89
#> Stationary Delta: 9.9924941689769e-06
#> Stationary step: 91
#> Stationary Delta: 9.40084451271455e-06
#> Stationary step: 86
#> Stationary Delta: 9.63494517713611e-06
#> Stationary step: 91
#> Stationary Delta: 9.41527435207838e-06
#> Stationary step: 90
#> Stationary Delta: 9.62972365628511e-06
#> Stationary step: 91
#> Stationary Delta: 9.70188006217768e-06
#> Stationary step: 89
#> Stationary Delta: 9.90701207172905e-06
#> Stationary step: 89
#> Stationary Delta: 9.65079481156828e-06
#> Stationary step: 90
#> Stationary Delta: 9.38601990000398e-06
#> Stationary step: 87
#> Stationary Delta: 9.64462357692525e-06
#> Stationary step: 85
#> Stationary Delta: 9.6448613103822e-06
#> Stationary step: 87
#> Stationary Delta: 9.45646087748305e-06
#> Stationary step: 90
#> Stationary Delta: 9.96637785890611e-06
#> Stationary step: 86
#> Stationary Delta: 9.91415710503968e-06
#> Stationary step: 85
#> Stationary Delta: 9.34645481726842e-06
#> Stationary step: 84
#> Stationary Delta: 9.60711315035213e-06
#> Stationary step: 89
#> Stationary Delta: 9.93236796300957e-06
#> Stationary step: 86
#> Stationary Delta: 9.79607302131185e-06
#> Stationary step: 85
#> Stationary Delta: 9.83796120922281e-06
#> Stationary step: 89
#> Stationary Delta: 9.65376875734204e-06
#> Stationary step: 90
#> Stationary Delta: 9.47086602447216e-06
#> Stationary step: 88
#> Stationary Delta: 9.74750948096003e-06
#> Stationary step: 92
#> Stationary Delta: 9.34454370647297e-06
#> Stationary step: 87
#> Stationary Delta: 9.61960049356026e-06
#> Stationary step: 89
#> Stationary Delta: 9.5836533392178e-06
#> Stationary step: 88
#> Stationary Delta: 9.62898159447236e-06
#> Stationary step: 91
#> Stationary Delta: 9.60393037077629e-06
#> Stationary step: 89
#> Stationary Delta: 9.84094865029031e-06
#> Stationary step: 89
#> Stationary Delta: 9.33925095066893e-06
#> Stationary step: 86
#> Stationary Delta: 9.86095028806403e-06
#> Stationary step: 91
#> Stationary Delta: 9.73811992152828e-06
#> Stationary step: 87
#> Stationary Delta: 9.60975469000762e-06
#> Stationary step: 81
#> Stationary Delta: 9.97974044282624e-06
#> Stationary step: 82
#> Stationary Delta: 9.50816474791502e-06
#> Stationary step: 88
#> Stationary Delta: 9.43850999418422e-06
#> Stationary step: 88
#> Stationary Delta: 9.84796729211651e-06
#> Stationary step: 90
#> Stationary Delta: 9.8904003078129e-06
#> Stationary step: 86
#> Stationary Delta: 9.34336347804814e-06
#> Stationary step: 88
#> Stationary Delta: 9.50510262006852e-06
#> Stationary step: 85
#> Stationary Delta: 9.63272600526055e-06
#> Stationary step: 91
#> Stationary Delta: 9.27745455618335e-06
#> Stationary step: 88
#> Stationary Delta: 9.63416584900158e-06
#> Stationary step: 91
#> Stationary Delta: 9.72584330874629e-06
#> Stationary step: 88
#> Stationary Delta: 9.84273274031922e-06
#> Stationary step: 87
#> Stationary Delta: 9.89355395473553e-06
#> Stationary step: 92
#> Stationary Delta: 9.86516808910632e-06
#> Stationary step: 90
#> Stationary Delta: 9.99916978398867e-06
#> Stationary step: 93
#> Stationary Delta: 9.82998113611414e-06
#> Stationary step: 91
#> Stationary Delta: 9.57038774795113e-06
#> Stationary step: 87
#> Stationary Delta: 9.44126338061181e-06
#> Stationary step: 89
#> Stationary Delta: 9.5035597876384e-06
#> Stationary step: 89
#> Stationary Delta: 9.97591755270488e-06
#> Stationary step: 90
#> Stationary Delta: 9.4230651707111e-06
#> Stationary step: 89
#> Stationary Delta: 9.84811093241172e-06
#> Stationary step: 90
#> Stationary Delta: 9.66554772718974e-06
#> Stationary step: 85
#> Stationary Delta: 9.62647990769813e-06
#> Stationary step: 87
#> Stationary Delta: 9.97240136120979e-06
#> Stationary step: 90
#> Stationary Delta: 9.46307538589671e-06
#> Stationary step: 86
#> Stationary Delta: 9.93659722563338e-06
#> Stationary step: 90
#> Stationary Delta: 9.33349447758953e-06
#> Stationary step: 87
#> Stationary Delta: 9.63930743865963e-06
#> Stationary step: 89
#> Stationary Delta: 9.28931891962738e-06
#> Stationary step: 85
#> Stationary Delta: 9.96012843398226e-06
#> Stationary step: 91
#> Stationary Delta: 9.33388606912197e-06
#> Stationary step: 88
#> Stationary Delta: 9.51958521159971e-06
#> Stationary step: 89
#> Stationary Delta: 9.76542828775555e-06
#> 100
#> cells passed 0.001 threshold: 12.89%
#> cells passed 0.01 threshold: 16.35%
#> cells passed 0.05 threshold: 26.24%
#> your emprical P value threshold: 0.05
#> what propertion of enriched cells over all cells: 26.24%
#> what propertion of seed cells that are enriched cells: 98.25%
#> fold of true cell over seed: 5.22