Skip to content
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

PLIER::num.pc error #17

Closed
msubirana opened this issue Mar 20, 2024 · 4 comments
Closed

PLIER::num.pc error #17

msubirana opened this issue Mar 20, 2024 · 4 comments

Comments

@msubirana
Copy link

I want to define the principle components for defining the range of k, but I got this error:

k <- PLIER::num.pc(data=gtex_expression_matrix_cm)
Error in if ((class(data) != "list") & (class(data) != "rsvd")) { : 
  the condition has length > 1

The gtex_expression_matrix_cm is the same object used i PLIER::PLIER and works perfectly.

@wgmao
Copy link
Owner

wgmao commented Mar 20, 2024

Thank you for your interest in the package. If you run class(gtex_expression_matrix_cm), you should see multiple values which leads to this error. One workaround is to use as.matrix(gtex_expression_matrix_cm) as input for num.pc.

@msubirana
Copy link
Author

gtex_expression_matrix_cm is already a matrix. If I use as.matrix(gtex_expression_matrix_cm) as input for num.pc, I encounter the same error.

@wgmao
Copy link
Owner

wgmao commented Mar 21, 2024

It should be easily solvable if I know more about the data. Without seeing the data, I would suggest to use the following code block.

rowNorm=function(x){
  s=apply(x,1,sd)
  m=apply(x,1,mean);
  x=sweep(x,1,m)
  x=sweep(x,1,s,"/")
  x
}

ng=nrow(gtex_expression_matrix_cm)
ns=ncol(gtex_expression_matrix_cm)
Y = rowNorm(gtex_expression_matrix_cm)

if (ns > 500){
svdres=rsvd::rsvd(Y, k=min(ns, max(200, ns/4)), q=3)
}else{
svdres=svd(Y)
}#else
#Then call num.pc(svdres)

@msubirana
Copy link
Author

Thanks now is working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants