Entering edit mode
3 months ago
prithvi.mastermind ▴ 50
I'm interested in plotting KM survival curve for genes based on median bifuraction of low and high expression groups. However, while running I;m getting an error stating that:
"Error in names(.cols) <- grp.levels : 'names' attribute  must be the same length as the vector "
My Code is as follows:
library(survival) library(survminer) library(dplyr) library(survMisc) library(GGally) library(survcomp) library(RegParallel) JMS <- read.delim(file = "SURVIVAL_47.txt") JMS = JMS %>% mutate(group = case_when(AURKA > quantile(AURKA, 0.5) ~ 'AURKA(High)', AURKA < quantile(AURKA, 0.5) ~ 'AURKA(Low)', TRUE ~ NA_character_ )) fit <- survfit(Surv(Time, Status) ~ AURKA, data = JMS) ggsurvplot(fit, pval = TRUE, conf.int = TRUE, risk.table = TRUE, risk.table.y.text.col = TRUE)
My data (SURVIVAL_47.txt") is available at:
Which line specifically is giving you this error?
The error seems fairly self explanatory: one of these functions is trying to assign column names as grp.levels (likely an internal variable), but the two objects are different lengths. In my experience there's a good chance this error stems from something simple like empty rows/columns in your starting .txt file, ambiguous group names, passing extra sample name/condition/group info columns to a function which is intended to only take a matrix of values, etc.