-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in tcrossprod(x, y) : requires numeric/complex matrix/vector arguments #27
Comments
Dear Marta, Thank you for reaching out and for your interest in using the Lamian package for your analysis. Based on the error message you've encountered (Error in tcrossprod(x, y) : requires numeric/complex matrix/vector arguments), it seems the issue arises from the input format or type of the arguments you're passing to the lamian_test() function, particularly those involved in the tcrossprod() operation within the function. This error typically occurs when tcrossprod() is called with non-numeric or incorrectly structured arguments. Here are a few suggestions to troubleshoot and resolve this issue: Check the Expression Matrix Format: Ensure that the expression matrix (expr) you're passing is a numeric matrix. The error might stem from using data@assays[["RNA"]]@CountS directly without ensuring it's in the correct format. You've correctly converted it to a matrix with as.matrix(), but it's worth double-checking that this matrix contains only numeric values. Verify the Design Matrix: Your design matrix construction seems correct, but ensure that it is indeed numeric and properly formatted. Sometimes, data conversion or subsetting operations might unintentionally alter the data type. It could be helpful to explicitly convert the intercept and group to numeric types if they are not already. Pseudotime Vector: Ensure that the pseudotime vector is purely numeric and correctly named with cell names. The naming of cells in the pseudotime vector should precisely match those in the expression matrix and cell annotation dataframe. Cell Annotation Data Frame: Double-check the cellanno dataframe to ensure that it's structured correctly with cell names and sample/group identifiers. The cell names (Cell) should match exactly those used in the expression matrix and pseudotime vector. Debugging Tips: Try running the lamian_test() function with a smaller subset of your data to see if the error persists. This could help isolate the issue. If after these checks the issue remains unresolved, it could be helpful to directly inspect the lamian_test() function's handling of the input arguments, particularly where tcrossprod() is called, to ensure compatibility with the inputs. Sometimes, directly debugging with a smaller set of data can reveal where the mismatch occurs. For example, you might also check if the values in the pseudotime are unique. I hope these suggestions help you move forward with your analysis. Please let me know how it works. Thanks! |
Dear Winnie, Thank you very much for your answer, I have implemented your suggestions but now I am encountering another error: I paste the actual code with the results form the tests that you suggested:
Best regards, Marta |
Dear Winnie, Just to inform you that I tried to apply lamian_test() after removing the cells with equal pseudotime and I still get the error: "Error in h(simpleError(msg, call)) : If you could shade some light into my problem would be great. Thank you very much in advance, Marta |
Hi Marta, If you are using the pseudotime output from slingshot, are you also referring to the section 'Apply other pseudotime inference methods in Lamian: take slingshot as an example" of the manual page https://winnie09.github.io/Wenpin_Hou/pages/Lamian.html#apply-other-pseudotime-inference-methods-in-lamian-take-slingshot-as-an-example? There are some operations to be taken for the pseudotime values before running Lamian. For example, the following lines are important:
|
Dear Wenpin, Thank you for your answer. Yes, I was following the section that you mentioned. Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000 4.019 8.506 9.518 14.187 21.009 |
Dear Lamian team,
Thank you very much for creating this tool, it looks really promising and useful for my analysis. However, I am facing an error.
I am studying the gene expression over time from two conditions (WT and KO) and I would like to apply your XDE test from module 3. I performed the pseudotime analysis with Slingshot and I am trying to use the function lamian_test() with test.type = 'variable' to know the genes that are differentially expressed between conditions along pseudotime.
My working object is a Seurat object where I have the pseudotime calculated with Slingshot in a slot in metadata. I have tried to supply all the arguments following your tutorial https://winnie09.github.io/Wenpin_Hou/pages/Lamian.html and trying to give them in the correct format (either data frames, matrices or vectors). But, I am obtaining the following error: Error in tcrossprod(x, y) : requires numeric/complex matrix/vector arguments
I am pasting my code here:
#Checking if all cells have pseudotime value
summary(data$slingshot_pseudotime_separated)
#Creating exp matrix
exp<-as.matrix(data@assays[["SCT"]]@DaTa)
#Creating design
intercept<-c("1","1")
group<-c("1","0")
Genotype<-c("WT","KO")
design<-data.frame(intercept,group)
row.names(design) <- Genotype
design<-as.matrix(design)
#Creating cell annotation
Geno<-as.data.frame(data$Genotype)
Cell<-row.names(Geno)
Geno_1<-Geno$
data$Genotype
cellanno<-data.frame(Cell,Geno_1)
#Creating pseudotime numeric vector with cell names
pseudotime<-data$slingshot_pseudotime_separated
names(pseudotime) <-Cell
#XDE test
Res <- lamian_test(
expr = as.matrix(data@assays[["RNA"]]@CountS),
cellanno = cellanno,
pseudotime = pseudotime,
design = design,
test.type = 'variable',
testvar = 2,
permuiter = 100,
This is for permutation test only.
We suggest that users use default permuiter = 100.
Alternatively, we can use test.method = 'chisq' to swich to the chi-square test.
ncores = 1
)
Could you please help me to find where is the error?
Thank you very much in advance and I wish you a nice day!
Marta
The text was updated successfully, but these errors were encountered: