Closed Zjianglin closed 1 month ago
Don't use leiden in find_marker_genes
res_key
, because of some reasons, it will be considered as a cluster result.
Similarly, louvain, phenograph, annotation, celltype and cell_type will also cause this error.
We can set the find_marker_genes
res_key
as a string that starts with marker_genes but doesn't contain the key words mentioned above.
Whether to use normalized data or raw data depends on the calculating effect, you can try to use both to see which is more effective.
Thanks for your reply @tanliwei-coder . The res_key
now can be set without leiden
in it.
As for the use_raw
for the find_marker_genes
, it has the use_raw (bool) – whether to use raw express matrix for analysis, default True.
in API page. I see that the similar function rank_genes_groups
in scanpy
noted that Expects logarithmized data.
.
Because the raw data backup code position is different in tutorial codes between scanpy
and stereopy
. I'd like to know for the find_marker_genes
in stereopy
, which kind of data is expected in the official method code implementation? i.e. the raw
means the entirely raw
from read_gef
without any preprocess or the logarithmized data
from normalize_total + log1p
?
What the raw data is depends on when you run the data.tl.raw_checkpoint
, raw_checkpoint
will saves the current state of data, that is to say, if you run raw_checkpoint
after read_gef
, it will saves the data without any processing, and if you run raw_checkpoint
after normalize_total
or log1p
, the raw is the one which has been normalized or logarithmized, normally, in some workflows of my company, we set the use_raw
as True, because the normalized data sometimes may cause some calculating errors which is casued by the internal logic of the algorithm.
Thanks for your reply. I tried it with use_raw
as False
.
After filter_marker_genes
, the results for some clusters is all NaN
except genes
column. is this means there is no DEG for this culster?
ms_data.tl.find_marker_genes(cluster_res_key=cls_key, use_highly_genes=False, use_raw =False,
res_key='marker_genes_{}'.format(cls_key.replace('leiden', 'ld')))
ms_data.tl.filter_marker_genes(marker_genes_res_key='marker_genes_{}'.format(cls_key.replace('leiden', 'ld')),
min_fold_change=0.5, min_in_group_fraction=0.25, max_out_group_fraction=0.5,
compare_abs=False, res_key='marker_genes_filtered_{}'.format(cls_key.replace('leiden', 'ld')),
output=ofp)
print( ms_data.merged_data.tl.result['marker_genes_filtered_ld1.5'].keys())
print( ms_data.merged_data.tl.result['marker_genes_filtered_ld1.5']['1.vs.rest'].head())
print( ms_data.merged_data.tl.result['marker_genes_filtered_ld1.5']['1.vs.rest'].isna().sum())
#==>
dict_keys(['parameters', 'pct', 'pct_rest', 'mean_count', '4.vs.rest', '1.vs.rest', '2.vs.rest', '3.vs.rest', '6.vs.rest', '7.vs.rest', '8.vs.rest', '5.vs.rest', '11.vs.rest', '10.vs.rest', '12.vs.rest', '9.vs.rest', '15.vs.rest', '13.vs.rest', '14.vs.rest'])
scores pvalues pvalues_adj log2fc genes pct pct_rest mean_count
0 NaN NaN NaN NaN Serpinb6a NaN NaN NaN
1 NaN NaN NaN NaN Crip1 NaN NaN NaN
2 NaN NaN NaN NaN Itgav NaN NaN NaN
3 NaN NaN NaN NaN Spp1 NaN NaN NaN
4 NaN NaN NaN NaN Col1a1 NaN NaN NaN
scores 18003
pvalues 18003
pvalues_adj 18003
log2fc 18003
genes 0
pct 18003
pct_rest 18003
mean_count 18003
dtype: int64
Thanks for your reply. I tried it with
use_raw
asFalse
. Afterfilter_marker_genes
, the results for some clusters is allNaN
exceptgenes
column. is this means there is no DEG for this culster?ms_data.tl.find_marker_genes(cluster_res_key=cls_key, use_highly_genes=False, use_raw =False, res_key='marker_genes_{}'.format(cls_key.replace('leiden', 'ld'))) ms_data.tl.filter_marker_genes(marker_genes_res_key='marker_genes_{}'.format(cls_key.replace('leiden', 'ld')), min_fold_change=0.5, min_in_group_fraction=0.25, max_out_group_fraction=0.5, compare_abs=False, res_key='marker_genes_filtered_{}'.format(cls_key.replace('leiden', 'ld')), output=ofp) print( ms_data.merged_data.tl.result['marker_genes_filtered_ld1.5'].keys()) print( ms_data.merged_data.tl.result['marker_genes_filtered_ld1.5']['1.vs.rest'].head()) print( ms_data.merged_data.tl.result['marker_genes_filtered_ld1.5']['1.vs.rest'].isna().sum()) #==> dict_keys(['parameters', 'pct', 'pct_rest', 'mean_count', '4.vs.rest', '1.vs.rest', '2.vs.rest', '3.vs.rest', '6.vs.rest', '7.vs.rest', '8.vs.rest', '5.vs.rest', '11.vs.rest', '10.vs.rest', '12.vs.rest', '9.vs.rest', '15.vs.rest', '13.vs.rest', '14.vs.rest']) scores pvalues pvalues_adj log2fc genes pct pct_rest mean_count 0 NaN NaN NaN NaN Serpinb6a NaN NaN NaN 1 NaN NaN NaN NaN Crip1 NaN NaN NaN 2 NaN NaN NaN NaN Itgav NaN NaN NaN 3 NaN NaN NaN NaN Spp1 NaN NaN NaN 4 NaN NaN NaN NaN Col1a1 NaN NaN NaN scores 18003 pvalues 18003 pvalues_adj 18003 log2fc 18003 genes 0 pct 18003 pct_rest 18003 mean_count 18003 dtype: int64
That is the result after filtering via ms_data.tl.filter_marker_genes
, it means that all the recoads are filtered out by the conditions you set.
Thanks for your reply. As the thresholds were relatively small, it may suggest that the cellbins
are too similar to distinguish them.
Hi, I tried to find markers/DEG between clusters of integrated MSdata object. It seems the
res_key
option can no be set except defaultmarker_genes
.I have seven Stereo-seq objects and made filter, merge, integrate and clustering. Here is my running code:
When I run the
ms_data.tl.find_marker_genes
withres_key='marker_genes_{}'.format(cls_key)
to set the DEG result oflaiden1.5
to amarker_genes_laiden1.5
, it crash out as below:I have two questions:
laiden1.5
clusters? i.e, should I use thenormalize_total + log1p
processed data or theuse_raw=True
fromms_data.tl.raw_checkpoint()
beforenormalize_total
?find_marker_genes
function can only save ares_key
asmarker_genes
? Could we set it as our demand? Thanks.