R/SQLite_ExpressionSummary.R

#' @name SQLite_ExpressionSummary
#' @aliases SQLite_ExpressionSummary,BioData-method
#' @rdname SQLite_ExpressionSummary-methods
#' @docType methods
#' @description Connect to a sqlite database and retrieve a gene read count summary for all the stored genes.
#' @param fname the file to the sqlite db
#' @title description of function SQLite_ExpressionSummary
#' @export 
setGeneric('SQLite_ExpressionSummary', ## Name
	function (fname ) { 
		standardGeneric('SQLite_ExpressionSummary')
	}
)

setMethod('SQLite_ExpressionSummary', signature = c ('character'),
	definition = function (fname ) {
	
	dbh <- RSQLite::dbConnect(RSQLite::SQLite(),dbname=fname )
	sth <- RSQLite::dbSendQuery(dbh, paste(  
					"SELECT gene_id , avg( value), count(value), gname" ,
					"from  datavalues left join genes on gene_id = genes.id",
					#			"where sample_id IN (select id from samples where sname not like '%spliced%')",  
					"GROUP by gene_id"
			)
	)
	ret <- RSQLite::dbFetch(sth)
	ret
} )
stela2502/BioData documentation built on Feb. 23, 2022, 5:47 a.m.