SCORPIUS icon indicating copy to clipboard operation
SCORPIUS copied to clipboard

group name error

Open CMSimpson8 opened this issue 2 years ago • 6 comments

I am having an issue using SCORPIUS, I want to set my progression group to show my Seurat clusters and the trajectory line between them - I am getting this error

Error in check_numeric_vector(progression_group, "progression_group", : ‘progression_group’ must be a numeric vector consisting of 2833 finite number(s)

the guide suggests setting the group name to Seuratobject$sample_info$group_name I have group set to mySeuratobject$meta.data$seurat_clusters

Is this the wrong subfile to set my group to? Which is the correct? I'm using R3.6.

Thanks!

CMSimpson8 avatar Jun 14 '22 10:06 CMSimpson8

Issue was partially solved by using as.numeric(data@seurat_clusters$[,1]) and contour = FALSE in the progression graph

CMSimpson8 avatar Jun 15 '22 09:06 CMSimpson8

Running into the same error...

VivianQM avatar Jun 16 '23 03:06 VivianQM

Hi! The progression_group expects a factor value. You have to change the numeric or character valued column/group of your metadata as factor. Like following:

Get the Group type from the metadata as a vector

group = c(metadata$group_col)

change the group to factor

group <- as.factor(group)

hope this helps.

asif7adil avatar Apr 12 '24 02:04 asif7adil

I have tried the above suggestions but still getting the error. My group names are 'Control_D5', 'Control_D7', 'Control_D9'. I have also tried swapping the group names to the cluster numbers instead (0-8) but still had the error.

> control
An object of class Seurat 
58153 features across 16728 samples within 2 assays 
Active assay: SCT (24615 features, 2000 variable features)
 3 layers present: counts, data, scale.data
 1 other assay present: RNA
 2 dimensional reductions calculated: pca, umap

> space <- reduce_dimensionality(control@assays$SCT@data, dist = "spearman", ndim = 3)
> control_group <- as.factor([email protected]$orig.ident)
> draw_trajectory_plot(space, progression_group = control_group, contour = TRUE)
Error in check_numeric_vector(progression_group, "progression_group",  : 
  ‘progression_group’ must be a numeric vector consisting of 24615 finite number(s)

Any help re this would be much appreciated!

shaln avatar Apr 17 '24 15:04 shaln

before converting your control group to a factor, it has to be taken as a vector. try this:

control_group <- c([email protected]$orig.ident)

control_group <- as.factor(control_group)

draw_trajectory_plot(space, progression_group = control_group, contour = TRUE)

Hope this helps!

asif7adil avatar Apr 17 '24 16:04 asif7adil

Hi @asif7adil, thanks for the suggestion! I'm afraid the same error still persists after trying that :(

> control_group <- c([email protected]$orig.ident)
> control_group <- as.factor(control_group)
> draw_trajectory_plot(space, progression_group = control_group, contour = TRUE)
Error in check_numeric_vector(progression_group, "progression_group",  : 
  ‘progression_group’ must be a numeric vector consisting of 24615 finite number(s)

> class(control_group)
[1] "factor"
> class(control_group[1])
[1] "factor"

shaln avatar Apr 18 '24 12:04 shaln

Is there some black magic? I have 11 rows in my matrix, creating the group_name by myself does not work:

<fake_group_name <- factor(c("MCP", "CDP", "PreDC", "PreDC",
                                                  "PreDC", "PreDC", "PreDC", "PreDC",
                                                  "PreDC", "PreDC", "PreDC",
                                               levels=c("CDP", "MCP", "PreDC")))
<fake_group_name
 [1] MCP   CDP   PreDC PreDC PreDC PreDC PreDC PreDC PreDC PreDC PreDC
Levels: CDP MCP PreDC
<draw_trajectory_plot(space, fake_group_name, contour = TRUE)
Error in `map()` at purrr/R/superseded-map-df.R:81:3:
ℹ In index: 1.
Caused by error in `if (any(h <= 0)) ...`:
! 需要TRUE/FALSE值的地方不可以用缺少值
Run `rlang::last_trace()` to see where the error occurred.

But if I just borrow the factor from example data, it worked!

<data(ginhoux)
<group_name <- ginhoux$sample_info$group_name
<group_name <- group_name[1:11]
<group_name
[1] CDP CDP CDP CDP CDP CDP CDP CDP CDP CDP CDP
Levels: MDP CDP PreDC
<draw_trajectory_plot(space, fake_group_name, contour = TRUE)

The plot poped out as expected! I'm very, very confused about the black magic here. The group_name in example data and the fake_group_name I created were all the same, class of both is "factor", "typeof" of both is "integer".

ZYF1997CN avatar May 08 '24 09:05 ZYF1997CN

Yeah I found out the weird unspoken rules. For every elements in the levels: If it appears in the factor, it must appears at least twice. Is it a feature or a bug?

ZYF1997CN avatar May 08 '24 09:05 ZYF1997CN