Error in -delete: invalid argument to unary operator
0
0
Entering edit mode
3.8 years ago

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")

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 • 13k views
0
Entering edit mode

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.

0
Entering edit mode

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, ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.6373547,"math_prob":0.9916239,"size":2264,"snap":"2023-40-2023-50","text_gpt3_token_len":749,"char_repetition_ratio":0.16637169,"word_repetition_ratio":0.009876544,"special_character_ratio":0.3891343,"punctuation_ratio":0.18801653,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99133945,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-11T16:21:58Z\",\"WARC-Record-ID\":\"<urn:uuid:5561239c-4d4c-49c2-a002-e38e1984bab0>\",\"Content-Length\":\"21882\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:65b2b59c-3d02-4028-a15a-86830934dc0c>\",\"WARC-Concurrent-To\":\"<urn:uuid:b927f543-6923-4972-9de6-7983c61a51b0>\",\"WARC-IP-Address\":\"45.79.169.51\",\"WARC-Target-URI\":\"https://www.biostars.org/p/424063/\",\"WARC-Payload-Digest\":\"sha1:RV2IVSLTRBTIQZ5BIABDRKNM764QZO65\",\"WARC-Block-Digest\":\"sha1:77SLHEEV7HLACM3OUECAMKUSFVY7NITT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679515260.97_warc_CC-MAIN-20231211143258-20231211173258-00888.warc.gz\"}"}