Question: Error in -delete: invalid argument to unary operator
0
gravatar for ovariohisterectomia
3 months ago by
ovariohisterectomia20 wrote:

hello and thank you in advance, to be brief, im doing a DE analysis in R, and first i want to delete the rows with 0 or N/A values. So im performing my script but at the end it sends me an error...here we go:

countData <- read.table("countData.txt", header = TRUE, dec = ".", sep = "\t", row.names = "GeneID")
colData <- read.table("colData.txt", header = TRUE, sep = "\t")
head(colData)

dds <- DESeqDataSetFromMatrix(countData = countData,
                              colData = colData,
                              design = ~treatment)

dds <- estimateSizeFactors(dds)
idx <- rowSums( counts(dds, normalized=TRUE) >= 2 ) >= 8 
dds <- dds[idx,]

dds <- DESeq(dds)
dds

normalized_counts <- counts(dds, normalized=TRUE)
View(normalized_counts)
write.table(as.data.frame(normalized_counts), file = "Count_DEseqNormCount.txt", sep = "\t", dec = ".")

y <- read.table("Count_DEseqNormCount.txt", dec = ".", sep = "\t", header = TRUE, row.names = 1)
names(y)
delete <- NULL


for (row in 1:nrow(y)) {

  flag1 <- FALSE
  flag2 <- FALSE


  if((y[row,1] == 0 && y[row,2] == 0 && y[row,3] == 0 && y[row,4] == 0 && y[row,5] == 0 && y[row,6] == 0) || (y[row,1] >= 1 && y[row,2] >= 1 && y[row,3] >= 1 && y[row,4] >= 1 && y[row,5] >= 1 && y[row,6] >= 1)) {
    flag1 <- TRUE
  } 
  if((y[row,7] == 0 && y[row,8] == 0 && y[row,9] == 0 && y[row,10] == 0 && y[row,11] == 0 && y[row,12] == 0) || (y[row,7] >= 1 && y[row,8] >= 1 && y[row,9] >= 1 && y[row,10] >= 1 && y[row,11] >= 1 && y[row,12] >= 1)) {
    flag2 <- TRUE
  } 

  if (flag1 == FALSE || flag2 == FALSE){
    delete <-c(delete, row)
  }
}

Until here, everything goes OK, but when i type this

y <- y[-delete,]

it says

Error in -delete : argumento no válido para un operador unitario

watching for a translation i think the error is this

Error in -delete : invalid argument to unary operator*

Would be very happy if you could help me, im really new in R and RNASeq. Thank you so much

rna-seq R • 379 views
ADD COMMENTlink written 3 months ago by ovariohisterectomia20

What is the content of delete? Are you sure you want && instead of &? What is this filtering going to do, I am sure there is a shorter way of expressing this query.

ADD REPLYlink modified 3 months ago • written 3 months ago by ATpoint34k

As suggested there are better ways of "filtering", reconsider using &, | instead of &&, I, read about rowSums, colSums.

If you are trying to negate, TRUE to FALSE, FALSE to TRUE, then we need: y <- y[ !delete, ]

ADD REPLYlink modified 3 months ago • written 3 months ago by zx87549.2k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1498 users visited in the last hour