Entering edit mode
23 months ago
a.basitkhan1990
▴
60
I am trying to use this R package on my data: https://github.com/WangX-Lab/PreMSIm
I generated a normalized counts file similar to example.txt in their example, except I used gene symbol instead of ID for row name.
When I run their sample code:
> library(PreMSIm)
> path = system.file("extdata", "example.txt", package = "PreMSIm", mustWork = TRUE)
> data_pre(path, type = "ID")
DDX27 EPM2AIP1 HENMT1 LYG1 MLH1 MSH4 NHLRC1 NOL4L RNLS RPL22L1 RTF2 SHROOM4 SMAP1 TTC30A ZSWIM3
Sample1 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.00000000 1.0000000 0.8761449 0.6029301 0.38125416 0.7734447 0.4684460 1.0000000 1.0000000 0.8196170
Sample2 0.2852962 0.7504918 0.9708924 0.8308378 0.9230994 0.29193800 0.6069412 0.2505053 1.0000000 0.32136905 0.0000000 1.0000000 0.7811169 0.5892737 0.8997000
Sample3 0.2925261 0.1905731 0.7926025 0.0000000 0.4826125 0.00000000 0.0628135 0.0000000 0.6856571 0.77711488 0.3534438 0.6395017 0.2431263 0.5991998 0.0000000
Sample4 0.3222120 0.3382536 0.0000000 0.0862332 0.9683453 0.00000000 0.0000000 0.1510892 0.2734307 0.08064167 0.6204359 0.0000000 0.6643792 0.2502177 0.2724272
Sample5 0.0000000 0.4358840 0.9106778 0.3425521 0.5230118 0.64636639 0.4365995 0.5848757 0.5989048 1.00000000 0.5013767 0.8444353 0.0000000 0.8413705 0.7055393
Sample6 0.9668400 0.0000000 0.7920770 0.3549156 0.0000000 0.16837552 0.1753813 1.0000000 0.0000000 0.00000000 1.0000000 0.2707480 0.6189015 0.0000000 1.0000000
Sample7 0.4824578 0.6602128 0.2860993 0.4002768 0.9693666 0.00000000 0.3152340 0.1379430 0.6548660 0.47439889 0.3435690 0.3907255 0.7911855 0.3374053 0.6464399
Sample8 0.7822241 0.7414237 0.4892138 0.2692035 0.7416527 0.08086024 0.5234921 0.6141626 0.7411251 0.53954477 0.3647259 0.4272453 0.7269801 0.6572230 0.4564439
library(PreMSIm)
path = system.file("extdata", "example.txt", package = "PreMSIm", mustWork = TRUE)
input_data = data_pre(path, type = "ID")
msi_pre(input_data)
I get the correct result:
Sample MSI_status
1 Sample1 0
2 Sample2 0
3 Sample3 1
4 Sample4 0
5 Sample5 1
6 Sample6 0
7 Sample7 0
8 Sample8 0
When I load my file from CSV or excel into R and then try to run mine I get this error:
> X <- read_excel("~/Desktop/Research/PatelMeningioma/SmokerDEG/countpremsim.xlsx")
> input_data = data_pre(X, type = "symbol")
Error in data_pre(X, type = "symbol") :
'input.path' is missing or incorrect
When I check the function it looks like the input needs to be a character:
> data_pre
function (input.path, type = c("Symbol", "ID"))
{
if (missing(input.path) || class(input.path) != "character")
stop("'input.path' is missing or incorrect")
type <- match.arg(type)
a <- read.table(input.path, stringsAsFactors = FALSE, header = TRUE,
row.names = 1, sep = "\t", check.names = FALSE)
if (TRUE %in% is.na(match(feature[, type], rownames(a)))) {
if (sum(!is.na(match(feature[, type], rownames(a)))) >=
5) {
feature <- feature[!is.na(match(feature[, type],
rownames(a))), ]
rownames(feature) <- NULL
}
else {
stop("Some features of the current test set are missing!")
}
}
a <- a[match(feature[, type], rownames(a)), , drop = FALSE]
if (FALSE %in% complete.cases(a))
stop("Predictor variables with missing values are presented in the current test set")
if (dim(a)[2] != 1) {
a <- apply(t(a), 2, function(x) {
(x - min(x))/(max(x) - min(x))
})
a[is.nan(a)] <- 1
}
else {
a <- t(a)
}
if (type == "ID") {
colnames(a) <- as.character(feature[, "Symbol"])
}
return(a)
}
<bytecode: 0x7f82451af3b0>
<environment: namespace:PreMSIm>
So I use this:
> input_data = data_pre(as.character(X), type = "Symbol")
But now I get this error:
Error in file(file, "rt") : invalid 'description' argument
All help is greatly appreciated