hartleys / JunctionSeq

The JunctionSeq R package is a powerful tool for testing and visualizing differential usage of exons and splice junctions in next-generation, high-throughput RNA-Seq experiments.
28 stars 15 forks source link

writeCompleteResults : Error in data.frame(..., check.names = FALSE) #53

Open YanliangDou opened 4 years ago

YanliangDou commented 4 years ago

Hi ,

When I run

writeCompleteResults(jscs, outfile.prefix="./output_R/")

there is one error

Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 491717, 0

My whole script like below:

`BiocManager::install("JunctionSeq")

library(JunctionSeq) library(JctSeqData)

###################### decoder <- read.table("decoder.bySample.txt",header=TRUE,stringsAsFactors=FALSE); design <- data.frame(condition = factor(decoder$group.ID)); geneID.to.symbol.file <- read.table("ensid.2.symbol.txt",header=TRUE,stringsAsFactors=FALSE); gff.file <- c("output_final/withNovel.forJunctionSeq.gff.gz");

The count files:

countFiles <- paste0("./output_final/",decoder$sample.ID,"/QC.spliceJunctionAndExonCounts.withNovel.forJunctionSeq.txt.gz"); ####################################################################################### jscs = readJunctionSeqCounts(countfiles = countFiles, samplenames = decoder$sample.ID, design = design, flat.gff.file = gff.file, gene.names = geneID.to.symbol.file, nCores = 1, verbose=TRUE, analysis.type = "junctionsAndExons" ); ######################################################################################

replace the estimation function with a version that takes an external size factor.

I Should have added this long ago...

estimateJunctionSeqSizeFactors.forced <- function( jscs , sizeFactors, verbose = FALSE){ stopifnot( is( jscs, "JunctionSeqCountSet") ) sizeFactors(jscs) <- sizeFactors sizeFactors(jscs@DESeqDataSet) <- rep(sizeFactors(jscs),2) fData(jscs)$baseMean <- rowMeans(counts(jscs, normalized= T)) fData(jscs)$baseVar <- rowVars(counts(jscs, normalized=T)) jscs@altSizeFactors <- data.frame() return(jscs);
}

Calculate size factors using your favorite method.

I recommend the upper quartile method, shown below:

SF <- sapply(1:ncol(jscs@geneCountData),function(i){ quantile(jscs@geneCountData[,i],p=0.75); })

Now copy in those size factors:

jscs <- estimateJunctionSeqSizeFactors.forced(jscs,sizeFactors=SF) ###########################################################################

writeSizeFactors(jscs, file = "sizeFactors.txt"); writeCompleteResults(jscs, outfile.prefix="./output_R/")`