Merging two plated in R
1
0
Entering edit mode
lmrogers34 ▴ 10
@lmrogers34-19639
Last seen 2.4 years ago
Germany

I am trying to merge two plates together in R. I have merged the plates and dropped rows as below. However, it keeps giving me this error message

"error in evaluating the argument 'x' in selecting a method for function 'ncol': argument "countData" is missing, with no default"

However, I can do ncol on my data just fine. I am not sure what is going on. Does anyone have any ideas?

countdata.P1=read.csv("all.p1.count", sep="", head=T, skip=1, row.names = "Geneid") # ignores first line
rawdata.P1=countdata.P1
# Clean file names
colnames(countdata.P1) <- gsub("\\.Aligned.sortedByCoord.out.bam", "_p1", colnames(countdata.P1))
colnames(countdata.P1) <- gsub("X.media.hard.drive3.TropI.scRNA_HIV.mapping.", "", colnames(countdata.P1))
countdata.P1 <- countdata.P1[ ,7:ncol(countdata.P1)] ## removing meta data
# Drop empty table, H12, renamed at read stage
countdata.P1 <- subset(countdata.P1, select=-c(H12_p1, G05_p1)) # Remove Row H12, empty sample, and G05 - not enough counts
write.table(countdata.P1, "counts_cleaned.txt", sep="\t", row.names=FALSE, quote=FALSE)

rna.metadata.P1 <- read.csv("metadata.p1.tab",sep = "\t", header = TRUE, row.names=1)
rna.metadata.P1 <- rna.metadata.P1[!(row.names(rna.metadata.P1) %in% c("G05")), ]
coldata.p1 <- data.frame(row.names=colnames(countdata.P1), rna.metadata.P1)

## Plate 2
countdata.p2=read.csv("all.p2.count", sep="", head=T, skip=1, row.names = "Geneid") # ignores first line
rawdata.p2=countdata.p2
# Clean file names
colnames(countdata.p2) <- gsub("\\_.fq.Aligned.sortedByCoord.out.bam", "_p2", colnames(countdata.p2))
colnames(countdata.p2) <- gsub("X.media.hard.drive3.TropI.scRNA_HIV.2020_12_17_reads.mapping.", "", colnames(countdata.p2))
countdata.p2 <- countdata.p2[ ,7:ncol(countdata.p2)] ## removing meta data
countdata.p2 <- subset(countdata.p2, select=-c(H12_p2)) # Remove Row H12, empty sample, and G05 - not enough counts


# Drop empty table, H12, renamed at read stage
write.table(countdata.p2, "counts_cleaned.txt", sep="\t", row.names=FALSE, quote=FALSE)
rna.metadata.p2 <- read.csv("metadata.p2.tab",sep = "\t", header = TRUE, row.names=1)
rna.metadata.p2 <- rna.metadata.p2[!(row.names(rna.metadata.p2) %in% c("p2_D4")), ]

coldata.p2 <- data.frame(row.names=colnames(countdata.p2), rna.metadata.p2)


coldata <- rbind(coldata.p1, coldata.p2) 
countdata <- merge(countdata.P1, countdata.p2, by=0)
dds_poscounts <- DESeqDataSetFromMatrix(countdata=as.matrix(countdata), colData=coldata, design=~plate + group)

sessionInfo( )

R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_IE.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_IE.UTF-8   
 [6] LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_IE.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_IE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] pheatmap_1.0.12             ggrepel_0.9.1               tibble_3.1.7                dplyr_1.0.9                
 [5] ggplot2_3.3.6               DESeq2_1.36.0               SummarizedExperiment_1.26.1 Biobase_2.56.0             
 [9] MatrixGenerics_1.8.0        matrixStats_0.62.0          GenomicRanges_1.48.0        GenomeInfoDb_1.32.1        
[13] IRanges_2.30.0              S4Vectors_0.34.0            BiocGenerics_0.42.0        

loaded via a namespace (and not attached):
 [1] locfit_1.5-9.5         Rcpp_1.0.8.3           lattice_0.20-45        png_0.1-7              Biostrings_2.64.0      assertthat_0.2.1      
 [7] utf8_1.2.2             R6_2.5.1               RSQLite_2.2.13         httr_1.4.3             pillar_1.7.0           zlibbioc_1.42.0       
[13] rlang_1.0.2            rstudioapi_0.13        annotate_1.74.0        blob_1.2.3             Matrix_1.4-1           splines_4.2.0         
[19] BiocParallel_1.30.0    geneplotter_1.74.0     RCurl_1.98-1.6         bit_4.0.4              munsell_0.5.0          DelayedArray_0.22.0   
[25] compiler_4.2.0         pkgconfig_2.0.3        tidyselect_1.1.2       KEGGREST_1.36.0        GenomeInfoDbData_1.2.8 XML_3.99-0.9          
[31] fansi_1.0.3            withr_2.5.0            crayon_1.5.1           bitops_1.0-7           grid_4.2.0             xtable_1.8-4          
[37] gtable_0.3.0           lifecycle_1.0.1        DBI_1.1.2              magrittr_2.0.3         scales_1.2.0           cli_3.3.0             
[43] cachem_1.0.6           XVector_0.36.0         genefilter_1.78.0      ellipsis_0.3.2         vctrs_0.4.1            generics_0.1.2        
[49] RColorBrewer_1.1-3     tools_4.2.0            bit64_4.0.5            glue_1.6.2             purrr_0.3.4            parallel_4.2.0        
[55] fastmap_1.1.0          survival_3.3-1         AnnotationDbi_1.58.0   colorspace_2.0-3       memoise_2.0.1
dese DESeq2 • 1.1k views
ADD COMMENT
2
Entering edit mode
@james-w-macdonald-5106
Last seen 1 day ago
United States

R is case-sensitive. Notice what you have as arguments to DESeqDataSetFromMatrix and what the error says.

ADD COMMENT
0
Entering edit mode

I am an idiot. Thanks. It was driving me mad! That's what I get from copying and pasting code from my old work.

ADD REPLY
1
Entering edit mode

Heh. I know how you feel. Can't tell you how many times I've sat here staring at some code thinking 'why does this not work!?!' I blame R, mostly. ;-D

ADD REPLY

Login before adding your answer.

Traffic: 804 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6