How to calculate the number of cells in different cell clusters with Seurat v3?
The "identities" can be accessed with the Idents() function in Seurat v3.

You should change cell.num &lt;- table(shox2crepos_mtmg@ident) to 

cell.num &lt;- table(Idents(shox2crepos_mtmg))