Search code examples
rdataframedoublemetadatadatamatrix

Datamatrix format problem in the pcpr2 package in R


I have been trying to run the pcpr2 package using the following tutorial: https://github.com/JoeRothwell/pcpr2

The data for this package is available in this link: https://github.com/JoeRothwell/pcpr2/raw/master/data/PCPR2data.RData

My datamatrix file is: https://drive.google.com/file/d/1wzzw2Jcui-IKICYc_QmTCvXqeFZ_3teX/view?usp=share_link

My metadata file is: https://drive.google.com/file/d/1d52Cj4qNvjTJox7n5uZKlmF9d8YPpfAn/view?usp=share_link

My code:

transcripts <- read.csv("test_matrix.csv", row.names = 1)

Z_metadata <- read.csv("test_trait.csv")

output <- runPCPR2(transcripts , Z_metadata, pct.threshold = 0.8)

Each time I try to use my data to run the codes from the pcpr2 package, I get the following error:

Error in runPCPR2(transcripts, Z_metadata, pct.threshold = 0.8) : 
  is.numeric(X_DataMatrix) is not TRUE

I tried converting my datamatrix into a numeric format by the following command:

transcripts  = lapply(transcripts , as.double) 

transcripts  = do.call("cbind", transcripts)

However, this didn't work also. I get another error message:

Error in solve.default(crossprod(model.matrix(mod))) : 
  Lapack routine dgesv: system is exactly singular: U[15,15] = 0

I can tell something is wrong with my datamatrix format as the datatype and the class ain't the same as the ones used in the tutorial. However, I don't understand how to fix this. Any sort of help will be greatly appriciated.


Solution

  • Be careful when importing the test_matrix dataset (there are rownames and it should be a matrix) :

    transcripts=as.matrix(read.csv("https://raw.githubusercontent.com/dtonmoy/PCPR2-data/main/test_matrix.csv",row.names=1))
    Z_metadata=read.csv("https://raw.githubusercontent.com/dtonmoy/PCPR2-data/main/test_trait.csv")
    
    output <- runPCPR2(transcripts , Z_metadata, pct.threshold = 0.8)