I am trying to run the qpcrImpute function on the nondetects package on R. I have normalised Ct values for 44 different microRNA for 8 patients and 11 controls, in total there are 836 observations. However some values are missing therefore I am trying to impute them. I have managed to create a qPCR class set, however I run into the following error:
library(HTqPCR)
# Read in table; need to be a matrix, so replace "ND" with NAs
in_data = read.table("C:\\Users\\Admin\\Desktop/david2019_TSV.txt", sep = "\t", stringsAsFactors = FALSE,
header = TRUE, row.names = 1, na.strings = "ND")
mat = as.matrix(in_data)
# qPCRset needs featureCategory with "OK", ""Undetermined" or "Unreliable" for each entry
feat_cat = as.data.frame(array("OK", dim=dim(mat)), stringsAsFactors = FALSE)
# Use "Undetermined" for entries corresponding to "ND" in dataset
feat_cat[is.na(mat)] = "Undetermined"
rownames(feat_cat) = rownames(mat)
colnames(feat_cat) = colnames(mat)
# Create new instance of qPCRset; needs featureNames to be added
raw = new("qPCRset", exprs = mat, featureCategory = feat_cat)
featureNames(raw) = rownames(mat)
# qPRCset object now created:
raw
#make identical pData(raw)$sample Name and colnames(exprs(raw)
pData(raw)$sampleName <- c("patient","patient.1","patient.2","patient.3","patient.4","patient.5","patient.6","patient.7","hc","hc.1","hc.2","hc.3","hc.4","hc.5","hc.6","hc.7","hc.8","hc.9","hc.10")
pData(raw)$sampleName
#deal with target genes
featureType(raw) <- c ("Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target","Target")
#EM algorithim
raw <- qpcrImpute(raw, dj = TRUE, pyfit = NULL, groupVars=c(NULL),
batch = NULL, tol = 1,
iterMax = 100, outform=c("Single"), formula = NULL,
linkglm = "logit")
**~0 + nrep
<environment: 0x000000001dea6358>
Error in Name.s2[ind2] <- names(tst$sigma[i]) :
replacement has length zero
In addition: Warning message:
Partial NA coefficients for 8 probe(s)**
I have attempted to add a value for length for the replacement using the length function in R but have been successful.
> length(raw$feat_cat) <- "40"
Warning message:
In length(raw$feat_cat) <- "40" : length of NULL cannot be changed
I was wondering if anyone would be able to help me with this problem.