You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The five rounds should all return different cells, while it always (but for the first round) returns the same cells.
Issue
Credits to wurli on Stackoverflow for figuring out the problem.
Seurat overloads [] to call subset.Seurat() which in turn calls WhichCells(), which has a default seed parameter of 1.
The first time our seed 12345 works (hence the first sample being different), but for the following rounds it is overwritten to 1.
Workaround
library(Seurat)
set.seed(12345)
for (i in 1:5)
{
ten_cells <- pbmc_small[, sample(Cells(pbmc_small), 5), seed=NULL]
print(Cells(ten_cells))
}
Not sure if removing the default seed with break other things, but this should probably be better documented as calling WhichCells overwrites the user seed, which is definitely unwanted behaviour.
The text was updated successfully, but these errors were encountered:
Problem
Wanting to randomly subset a Seurat object, one could do
This prints
Expected behaviour
The five rounds should all return different cells, while it always (but for the first round) returns the same cells.
Issue
Credits to wurli on Stackoverflow for figuring out the problem.
Seurat overloads
[]
to callsubset.Seurat()
which in turn callsWhichCells()
, which has a default seed parameter of 1.The first time our seed 12345 works (hence the first sample being different), but for the following rounds it is overwritten to 1.
Workaround
This prints
Proposed solution
Not sure if removing the default seed with break other things, but this should probably be better documented as calling WhichCells overwrites the user seed, which is definitely unwanted behaviour.
The text was updated successfully, but these errors were encountered: