Skip to content

Commit

Permalink
Added fixed files for commit
Browse files Browse the repository at this point in the history
  • Loading branch information
egaleota committed Jul 5, 2018
1 parent e7500df commit 0b10e03
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
30 changes: 15 additions & 15 deletions R/GEOHandler.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#' @name connectToGEODB
#' @aliases connectToGEODB, GEOHandler-function
#' @rdname GEOHandler-functions
#' @param sqliteFileName optional SQLite file path of the SQLite database if already downloaded
#' @param sqliteFilePath optional SQLite full file path of the SQLite database if already downloaded
#' @param download If TRUE allow the automatic downloading of the database file.
#' @param destdir optional destination directory
#' @param destdir optional destination directory. Current working directory is the default
#' @return A connection to the GEOmetadb
#' @description This method allows users to connect to the GEOmetadb downloaded. If no parameter is provided than the function retrieves the database in sqlite format and returns a connection to query the database
#' @examples
Expand All @@ -19,20 +19,20 @@
#' @export
#' @importFrom GEOmetadb getSQLiteFile
#' @importFrom RSQLite dbConnect SQLite
connectToGEODB <- function(sqliteFileName = NULL, download = FALSE, destdir = getwd()) {
connectToGEODB <- function(sqliteFilePath = NULL, download = FALSE, destdir = getwd()) {
geo_con <- NA
if (is.null(sqliteFileName)) {
# set the filename to default
if(download==TRUE){
if(dir.exists(destdir)){
sqliteFileName <- "GEOmetadb.sqlite"
}


if (!file.exists(file.path(destdir, sqliteFileName)) & download == TRUE) {
sqlfile <- GEOmetadb::getSQLiteFile(destdir = destdir)
sqliteFilePath = file.path(destdir, sqliteFileName)
}
}

if (file.exists(file.path(destdir, sqliteFileName)))
geo_con <- RSQLite::dbConnect(SQLite(), sqliteFileName) else stop("please provide a valid connection")

if(file.exists(sqliteFilePath))
geo_con <- RSQLite::dbConnect(RSQLite::SQLite(), sqliteFilePath)
else
message('Please provide the valid full path for GEOmetadb.sqlite file')
return(geo_con)
}

Expand Down Expand Up @@ -124,7 +124,7 @@ getGEOMetadata <- function(geo_con, experiment_type = NA, organism = NA, gpl = N
stop("Invalid experiment type. Please run experiment_types(GEOcon) to view valid values")
experiment_query <- paste0("select gse, title, summary from gse where type ='",
experiment_type, "'")
experiment_metadata <- dbGetQuery(geo_con, experiment_query)
experiment_metadata <- RSQLite::dbGetQuery(geo_con, experiment_query)
colnames(experiment_metadata) <- c("gse", "experiment_title", "experiment_summary")
experiment_acs <- unique(experiment_metadata$gse)
}
Expand All @@ -148,9 +148,9 @@ getGEOMetadata <- function(geo_con, experiment_type = NA, organism = NA, gpl = N
if (!is.na(gpl)) {
sample_query <- paste0(sample_query, statement, " gpl = '", gpl, "'")
}
sample_metadata <- dbGetQuery(geo_con, sample_query)
sample_metadata <- RSQLite::dbGetQuery(geo_con, sample_query)
columns <- c(2, 1, 3:ncol(sample_metadata))
if (!is.na(experiment_metadata)) {
if (is.data.frame(experiment_metadata) & nrow(experiment_metadata)>=1) {
geo_metadata <- merge(sample_metadata, experiment_metadata, by.x = "series_id",
by.y = "gse")
columns <- c(2, 3, 5, 7, 8, 9, 10, 1, 4, 6)
Expand Down
7 changes: 5 additions & 2 deletions R/globalAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ annotateTissueDisease <- function(geo_metadb_path, gsm_list, tissue_obo, disease
outdir, height_threshold, score_matrix) {

message("Connecting to the GEOmetadb")
geo_con <- connectToGEODB(sqliteFileName = "GEOmetadb.sqlite", destdir = geo_metadb_path)

if(file.exists(geo_metadb_path))
geo_con <- connectToGEODB(sqliteFilePath = geo_metadb_path)
else
geo_con <- connectToGEODB(download=TRUE, destdir = geo_metadb_path)

message("Retrieving GSM metadata")
gsm_list <- as.character(as.vector(gsm_list))
gsm_list <- paste0("'", paste(gsm_list, collapse = "', '"), "'")
Expand Down
6 changes: 3 additions & 3 deletions man/GEOHandler-functions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 22 additions & 5 deletions vignettes/Onassis.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ vignette: >
%\VignetteDepends{Onassis}
---

```{r imports, echo=FALSE,eval=TRUE, message=FALSE}
```{r imports, echo=FALSE,eval=TRUE, message=FALSE, warning=FALSE}
library(Onassis)
library(DT)
library(gplots)
library(org.Hs.eg.db)
```

# Introduction to OnASSis
Expand All @@ -41,6 +40,17 @@ Onassis can handle any type of text as input, but is particularly well suited fo
The semantic similarity module uses different semantic similarity measures to determine the semantic similarity of concepts in a given ontology. This
module has been developed on the basis of the Java slib http://www.semantic-measures-library.org/sml.
To run Onassis Java (>= 1.8) is needed.
For the correct working of the following examples please install the following libraries:

```{r echo=TRUE, eval=FALSE}
source("https://bioconductor.org/biocLite.R")
biocLite('org.Hs.eg.db')
biocLite("GenomicRanges")
install.packages('data.table')
install.packages('DT')
install.packages('gplots')
```

# Retrieving public repositories metadata

Expand All @@ -53,7 +63,7 @@ First, it is necessary to obtain and get a connection to the SQLite database. `c

```{r connectTodb, echo=TRUE,eval=FALSE}
## Running this function might take long time if the database has to be downloaded.
geo_con <- connectToGEODB(system.file(getwd(), 'GEOmetadb.sqlite'))
geo_con <- connectToGEODB(download=TRUE)
#Showing the experiment types available in GEO
experiments <- experiment_types(geo_con)
Expand Down Expand Up @@ -478,10 +488,17 @@ filtered_onassis <- sim(filtered_onassis)
Annotations with semantic similarities above a given threshold can be unified using the method `collapse`. This method unifies the similar annotations by concatenating their unique concepts. Entities are replaced with the new concatenated annotations. For each concept in the concatenated annotations the number of samples associated is also reported, together with the total number of samples annotated with the new annotations.
The similarity slot will be consequently updated

```{r collapsing_similarities, echo=TRUE, eval=TRUE}
```{r collapsing_similarities, echo=TRUE, eval=TRUE, fig.width=5, fig.height=5}
collapsed_onassis <- Onassis::collapse(filtered_onassis, 0.8)
head(entities(collapsed_onassis))
heatmap.2(simil(collapsed_onassis))
heatmap.2(simil(collapsed_onassis), margins=c(15,15), cexRow = 1, cexCol = 1)
```

# Session Info

Here is the output of the sessionInfo() on the system on which this document was compiled through kintr:
`{r sessionInfo(), echo=FALSE, eval=TRUE}
sessionInfo()
```
# References

0 comments on commit 0b10e03

Please sign in to comment.