Contents

1 Introduction

InterMine is a powerful open source data warehouse system integrating diverse biological data sets (e.g. genomic, expression and protein data) for various organisms. Integrating data makes it possible to run sophisticated data mining queries that span domains of biological knowledge. A selected list of databases powered by InterMine is shown in Table 1:

Database Organism Data
FlyMine Drosophila Genes, homology, proteins, interactions, gene ontology, expression, regulation, phenotypes, pathways, diseases, resources, publications
HumanMine H. sapiens Genomics, SNPs, GWAS, proteins, gene ontology, pathways, gene expression, interactions, publications, disease, orthologues, alleles
MouseMine M. musculus Genomics, proteins, gene ontology, expression, interactions, pathways, phenotypes, diseases, homology, publications
RatMine R. norvegicus Disease, gene ontology, genomics, interactions, phenotype, pathway, proteins, publication QTL, SNP
WormMine C. elegans Genes, alleles, homology, go annotation, phenotypes, strains
YeastMine S. cerevisiae Genomics, proteins, gene ontology, comparative genomics, phenotypes, interactions, literature, pathways, gene expression
ZebrafishMine D. rerio Genes, constructs, disease, gene ontology, genotypes, homology, morpholinos, phenotypes
TargetMine H. sapiens, M. musculus Genes, protein structures, chemical compounds, protein domains, gene function, pathways, interactions, disease, drug targets
MitoMiner H. sapiens, M. musculus, R. norvegicus, D. rerio, S. cerevisiae, S. pombe Genes, homology, localisation evidence, Mitochondrial reference gene lists, phenotypes, diseases, expression, interactions, pathways, exome
IndigoMine Archae Genomics
ThaleMine A. thaliana Genomics, proteins, domains, homology, gene ontology, interactions, expression, publications, pathways, GeneRIF, stocks, phenotypes, alleles, insertions, TAIR
MedicMine Medicago truncatula Genomics, pathways, gene ontology, publications, proteins, homology
PhytoMine over 50 plant genomes Genes, proteins, expression, transcripts, homology

Please see the InterMine home page for a full list of available InterMines.

InterMine includes an attractive, user-friendly web interface that works ‘out of the box’ and a powerful, scriptable web-service API to allow programmatic access to your data. This R package provides an interface with the InterMine-powered databases through Web services.

2 Jumpstart: How to build queries using InterMineR

Let’s start with a simple task - find the pathways of the gene ABO.

2.1 Select a database

First, we look at what databases are available.

library(InterMineR)
listMines()
##                                                AllianceMine 
##              "https://www.alliancegenome.org/alliancemine/" 
##                                                    AquaMine 
##               "https://aquamine.rnet.missouri.edu/aquamine" 
##                                                        BMAP 
##                        "https://bmap.jgi.doe.gov/bmapmine/" 
##                                                     CHOmine 
##                        "https://chomine.boku.ac.at/chomine" 
##                                                   FAANGMine 
##             "https://faangmine.rnet.missouri.edu/faangmine" 
##                                                     FlyMine 
##                           "https://www.flymine.org/flymine" 
##                                                   GrapeMine 
##                  "http://urgi.versailles.inra.fr/GrapeMine" 
##                                                   HumanMine 
##                       "https://www.humanmine.org/humanmine" 
##                                             HymenopteraMine 
## "https://hymenopteramine.rnet.missouri.edu/hymenopteramine" 
##                                                  IndigoMine 
##                       "http://www.cbrc.kaust.edu.sa/indigo" 
##                                                  LegumeMine 
##                   "https://mines.legumeinfo.org/legumemine" 
##                                                   MaizeMine 
##             "https://maizemine.rnet.missouri.edu/maizemine" 
##                                                   MouseMine 
##                        "http://www.mousemine.org/mousemine" 
##                                                     OakMine 
##              "https://urgi.versailles.inra.fr/OakMine_PM1N" 
##                                                   PhytoMine 
##                  "https://phytozome.jgi.doe.gov/phytomine/" 
##                                                  TargetMine 
##            "https://targetmine.mizuguchilab.org/targetmine" 
##                                                   ThaleMine 
##                         "https://bar.utoronto.ca/thalemine" 
##                                                   WheatMine 
##                 "https://urgi.versailles.inra.fr/WheatMine" 
##                                                    WormMine 
##             "http://intermine.wormbase.org/tools/wormmine/" 
##                                                     XenMine 
##                            "http://www.xenmine.org/xenmine" 
##                                                   YeastMine 
##               "https://yeastmine.yeastgenome.org/yeastmine"

Since we would like to query human genes, we select HumanMine.

# load HumaMine
im <- initInterMine(mine=listMines()["HumanMine"])
im
## An object of class "Service"
## Slot "mine":
##                             HumanMine 
## "https://www.humanmine.org/humanmine" 
## 
## Slot "token":
## [1] ""

2.2 Obtain a prebuilt query

Both in InterMine database website and in InterMineR, you are able to build custom queries. However, to facilitate the retrieval of information from InterMine databases, a variety of pre-built queries, called templates, have also been made available. Templates are queries that have already been created with a fixed set of output columns and one or more constraints.

# Get template (collection of pre-defined queries)
template = getTemplates(im)
head(template)
##                         name
## 1 Tissue_Expression_illumina
## 2          humDisGeneOrthol2
## 3              PhenotypeGene
## 4                disExprGene
## 5       protein_interactions
## 6         Gene_Interactions2
##                                                  title
## 1       Tissue --> Gene Expression (Illumina body map)
## 2    Human Disease --> Human Gene + Orthologue Gene(s)
## 3 Mouse Phenotype -->  Mouse Genes + Orthologous genes
## 4                         Disease Expression --> Genes
## 5                             Protein --> Interactions
## 6                                Gene --> Interactions

We would like to find templates involving genes.

# Get gene-related templates
template[grep("gene", template$name, ignore.case=TRUE),]
##                                   name
## 2                    humDisGeneOrthol2
## 3                        PhenotypeGene
## 4                          disExprGene
## 6                   Gene_Interactions2
## 7                   Protein_Gene_Ortho
## 8                          GOterm_Gene
## 11                 Disease_gene_RNAseq
## 12               Gene_Alleles_Disease2
## 14          ChromRegion_GenesTransExon
## 17                         GeneExpress
## 18                      Disease_Genes2
## 19                       Gene_Location
## 20        Protein_GeneChromosomeLength
## 21                    Gene_Identifiers
## 23                        Gene_Pathway
## 26               Gene_protein_sequence
## 27                        PathwayGenes
## 29                        Gene_Protein
## 30              Gene_OverlapppingGenes
## 33              DiseaseDisGenNet_GEnes
## 34                Gene_To_Publications
## 35     Gene_Interactions_forReportPage
## 36                    Gene_Disease_HPO
## 37                             Gene_GO
## 39           GeneInteractorsExpression
## 40         Gene_particularGoannotation
## 41       Gene_TissueExpressionIllumina
## 43                 Gene_HPOphenotype_2
## 44                 domain_protein_gene
## 45                Gene_Expression_GTex
## 46                      Gene_DisGenNet
## 47         Gene_ExpressionProteinAtlas
## 48                 Pathway_ProteinGene
## 49                    Gene_description
## 52                         DepMap_Gene
## 53               Gene_Interact_disease
## 54               GeneHPOparent_Genes_2
## 55                  Gene_proteindomain
## 56                            HPO_Gene
## 57                         Gene_SigSNP
## 58                         Gene_inGWAS
## 59                   geneGWAS_reportPg
## 60                 geneInteractiongene
## 61                       Gene_Disease2
## 62             Term_inGWASoptionalGene
## 63        Gene_proteinAtlasExpression2
## 64                      GeneOrthAllele
## 66 Gene_Interactions_DiseaseExpression
## 69                           Gene_Orth
## 70                   ChromRegion_Genes
## 72           GenePathway_interactions2
## 73                     Gene_AllelePhen
##                                                                          title
## 2                            Human Disease --> Human Gene + Orthologue Gene(s)
## 3                         Mouse Phenotype -->  Mouse Genes + Orthologous genes
## 4                                                 Disease Expression --> Genes
## 6                                                        Gene --> Interactions
## 7                                             Protein --> Gene and Orthologues
## 8                                                            GO term --> Genes
## 11                                       Disease -> Genes + RNA-seq Expression
## 12                                 Gene --> Alleles and Disease (clinVar data)
## 14                    Chromosomal Location --> All Genes + Transcripts + Exons
## 17       Gene --> Gene Expression  (Tissue, Disease; Array Express, E-MTAB-62)
## 18                                                         Disease --> Gene(s)
## 19                                              Gene --> Chromosomal location.
## 20                                                           Protein --> Gene.
## 21                                                   Gene --> All identifiers.
## 23                                                            Gene --> Pathway
## 26                                          Gene -> Protein + protein sequence
## 27                                                           Pathway --> Genes
## 29                                                          Gene --> Proteins.
## 30                                                 Gene --> Overlapping genes.
## 33                                    Disease association --> genes (DisGeNet)
## 34                                                      Gene --> Publications.
## 35                                  Gene --> Physical and Genetic Interactions
## 36               Gene --> Disease + HPO annotations (Human Phenotype Ontology)
## 37                                                          Gene --> GO terms.
## 39 Gene + Tissue Expression  --> Interactors that are expressed in that tissue
## 40                                         Gene + GO term --> Genes by GO term
## 41                              Gene --> Tissue Expression (Illumina body map)
## 43                           Gene -> HPO annotation (Human Phenotype Ontology)
## 44                                        Protein Domain --> Protein and Genes
## 45                                      Gene --> Tissue Expression (GTex data)
## 46                                Gene(s) --> Disease Associations (DisGenNet)
## 47                       Gene(s) --> Tissue Expression (Protein Atlas RNA-seq)
## 48                                                Pathway --> Protein and Gene
## 49                                                         Gene -> Description
## 52                                        Cancer cell line --> Gene Expression
## 53                                             Gene -> Interactions + diseases
## 54                                   Gene + HPO Phenotype parent term -> Genes
## 55                                                  Gene --> Protein + Domains
## 56                                                          HPO term --> Genes
## 57                                    Gene(s) --> Significant SNPs (GTex data)
## 58                                                           Gene --> GWAS hit
## 59                                                    Gene Report --> GWAS hit
## 60                                           Gene A --> Interaction <-- Gene B
## 61                                                     Gene --> Disease (OMIM)
## 62                            GWAS term --> SNP + Associated gene if available
## 63                                        Gene --> Protein tissue Localisation
## 64                              Gene (Hum OR Rat) --> Mouse Allele (Phenotype)
## 66                      Gene(s) + Disease --> Interactors + Disease Expression
## 69                                                        Gene --> Orthologues
## 70                                                            Region --> Genes
## 72                                             Gene + Pathway --> Interactions
## 73                                           Mouse Gene --> Allele [Phenotype]

The template Gene_Pathway seems to be what we want. Let’s look at this template in more detail.

# Query for gene pathways
queryGenePath = getTemplateQuery(
  im = im, 
  name = "Gene_Pathway"
)
queryGenePath
## $model
##      name 
## "genomic" 
## 
## $title
## [1] "Gene --> Pathway"
## 
## $description
## [1] "For a given Gene (or List of Genes) show any associated Pathway(s) (Data Source: KEGG or REACTOME). Keywords: pathways, metabolism, cascade "
## 
## $select
## [1] "Gene.primaryIdentifier"      "Gene.symbol"                
## [3] "Gene.name"                   "Gene.pathways.name"         
## [5] "Gene.pathways.dataSets.name" "Gene.pathways.identifier"   
## [7] "Gene.organism.shortName"    
## 
## $constraintLogic
## [1] "B and A"
## 
## $name
## [1] "Gene_Pathway"
## 
## $comment
## [1] "Added 26OCT2010: ML"
## 
## $tags
## [1] "im:aspect:Function" "im:aspect:Pathways" "im:public"         
## 
## $rank
## [1] "1"
## 
## $authorized
## [1] FALSE
## 
## $orderBy
## $orderBy[[1]]
## Gene.primaryIdentifier 
##                  "ASC" 
## 
## $orderBy[[2]]
## Gene.primaryIdentifier 
##                  "ASC" 
## 
## $orderBy[[3]]
## Gene.primaryIdentifier 
##                  "ASC" 
## 
## 
## $where
## $where[[1]]
## $where[[1]]$path
## [1] "Gene"
## 
## $where[[1]]$op
## [1] "LOOKUP"
## 
## $where[[1]]$code
## [1] "A"
## 
## $where[[1]]$editable
## [1] TRUE
## 
## $where[[1]]$switchable
## [1] FALSE
## 
## $where[[1]]$switched
## [1] "LOCKED"
## 
## $where[[1]]$value
## [1] "pparg"
## 
## 
## $where[[2]]
## $where[[2]]$path
## [1] "Gene.organism.name"
## 
## $where[[2]]$op
## [1] "="
## 
## $where[[2]]$code
## [1] "B"
## 
## $where[[2]]$editable
## [1] TRUE
## 
## $where[[2]]$switchable
## [1] FALSE
## 
## $where[[2]]$switched
## [1] "LOCKED"
## 
## $where[[2]]$value
## [1] "Homo sapiens"

There are three essential members in a query - SELECT, WHERE and constraintLogic.

  1. SELECT
    1. The SELECT (or view) represents the output columns in the query output.
    2. Columns of a view are usually of the form “A.B”, where B is the child of A. For example in the column Gene.symbol, symbol is the child of Gene. Columns could also be in cascade form “A.B.C”. For example, in the column Gene.locations.start, locations is the child of Gene and start is the child of locations.
  2. WHERE
    1. The WHERE statement is a collection of constraints.
    2. Query constraints include a list of the following columns:
      1. path
        1. in the same format as view columns
      2. op
        1. the constraint operator
        2. Valid values: “=”, “!=”, “LOOKUP”, “ONE OF”, “NONE OF”, “>”, “<”, “>=”, “<=”, “LIKE”
      3. value 1. the constraint value
      4. code
        1. Ignore
        2. The logic code for the constraint (e.g. A, B or C).
        3. Only used in the constrainLogic (discussed below
      5. extraValue
        1. optional, required for LOOKUP constraints
        2. Short name of organism, e.g. H. sapiens
        1. Editable
          1. Ignore
          2. Used to determine if user is allowed to edit this constraint. Only for the UI.
      6. Switchable
        1. Ignore
        2. Used to determine if user is allowed to disable this constraint.
          Only for the UI.
      7. Switched
        1. Ignore
        2. Used to determine if user has enabled this constraint. Only for the UI.
  3. constraintLogic
    1. Constraint Logic, if not explicitly given, is “AND” operation, e.g., “A and B”, where A and B are the codes in the constraints.

2.2.1 Look at the data model

What does ‘Gene.symbol’ mean? What is ‘Gene.pathway.identifier’?

Let’s take a look at the data model. NOTE: Section temporarily removed due to errors

3 ```{r getModel, warning=FALSE, message=FALSE}

4 model <- getModel(im)

5 head(model)


Let's look at the children of the Gene data type.

# ```{r gene_type_data, warning=FALSE, message=FALSE}

# model[which(model$type=="Gene"),]

Gene has a field called ‘symbol’ (hence the column Gene.symbol). Gene also references the Pathways class, which is of the Pathway data type.

6 ```{r pathway_type, warning=FALSE, message=FALSE}

7 model[which(model$type==“Pathway”),]




## Run a Query
Let's now run our template.


```r
resGenePath <- runQuery(im, queryGenePath)
head(resGenePath)
##   Gene.primaryIdentifier Gene.symbol
## 1                   5468       PPARG
## 2                   5468       PPARG
## 3                   5468       PPARG
## 4                   5468       PPARG
## 5                   5468       PPARG
## 6                   5468       PPARG
##                                          Gene.name
## 1 peroxisome proliferator activated receptor gamma
## 2 peroxisome proliferator activated receptor gamma
## 3 peroxisome proliferator activated receptor gamma
## 4 peroxisome proliferator activated receptor gamma
## 5 peroxisome proliferator activated receptor gamma
## 6 peroxisome proliferator activated receptor gamma
##                             Gene.pathways.name Gene.pathways.dataSets.name
## 1                        Developmental Biology  Reactome pathways data set
## 2              Gene expression (Transcription)  Reactome pathways data set
## 3                Generic Transcription Pathway  Reactome pathways data set
## 4 Intracellular signaling by second messengers  Reactome pathways data set
## 5        MECP2 regulates transcription factors  Reactome pathways data set
## 6                                   Metabolism  Reactome pathways data set
##   Gene.pathways.identifier Gene.organism.shortName
## 1            R-HSA-1266738              H. sapiens
## 2              R-HSA-74160              H. sapiens
## 3             R-HSA-212436              H. sapiens
## 4            R-HSA-9006925              H. sapiens
## 5            R-HSA-9022707              H. sapiens
## 6            R-HSA-1430728              H. sapiens

8 Modify a Query

8.1 Edit a constraint

Let’s modify the query to find the pathways of the gene ABO. We want to change the ‘value’ attribute from PPARG to ABO.

There are two ways to build a query in InterMineR.

  1. We can either build a query as a list object with newQuery function, and assign all input values (selection of retrieved data type, constraints, etc.) as items of that list,

  2. Or we can build the query as an InterMineR-class object with the functions setConstraint, which allows us to generate a new or modify an existing list of constraints, and setQuery, which generates the query as a InterMineR-class object.

setConstraints and setQuery functions are designed to facilitate the generation of queries for InterMine instances and avoid using multiple iterative loops, especially when it is required to include multiple constraints or constraint values (e.g. genes, organisms) in your query.

# modify directly the value of the first constraint from the list query
queryGenePath$where[[1]][["value"]] <- "ABO"

# or modify the value of the first constraint from the list query with setConstraints
queryGenePath$where = setConstraints(
  modifyQueryConstraints = queryGenePath,
  m.index = 1,
  values = list("ABO")
)

queryGenePath$where
## [[1]]
## [[1]]$path
## [1] "Gene"
## 
## [[1]]$op
## [1] "LOOKUP"
## 
## [[1]]$code
## [1] "A"
## 
## [[1]]$editable
## [1] TRUE
## 
## [[1]]$switchable
## [1] FALSE
## 
## [[1]]$switched
## [1] "LOCKED"
## 
## [[1]]$value
## [1] "ABO"
## 
## 
## [[2]]
## [[2]]$path
## [1] "Gene.organism.name"
## 
## [[2]]$op
## [1] "="
## 
## [[2]]$code
## [1] "B"
## 
## [[2]]$editable
## [1] TRUE
## 
## [[2]]$switchable
## [1] FALSE
## 
## [[2]]$switched
## [1] "LOCKED"
## 
## [[2]]$value
## [1] "Homo sapiens"

Note the value is now equal to ‘ABO’. Let’s rerun our query with the new constraint.

resGenePath <- runQuery(im, queryGenePath)
head(resGenePath)
##   Gene.primaryIdentifier Gene.symbol
## 1                     28         ABO
## 2                     28         ABO
## 3                     28         ABO
## 4                     28         ABO
##                                                                              Gene.name
## 1 ABO, alpha 1-3-N-acetylgalactosaminyltransferase and alpha 1-3-galactosyltransferase
## 2 ABO, alpha 1-3-N-acetylgalactosaminyltransferase and alpha 1-3-galactosyltransferase
## 3 ABO, alpha 1-3-N-acetylgalactosaminyltransferase and alpha 1-3-galactosyltransferase
## 4 ABO, alpha 1-3-N-acetylgalactosaminyltransferase and alpha 1-3-galactosyltransferase
##                 Gene.pathways.name Gene.pathways.dataSets.name
## 1     ABO blood group biosynthesis  Reactome pathways data set
## 2 Blood group systems biosynthesis  Reactome pathways data set
## 3                       Metabolism  Reactome pathways data set
## 4      Metabolism of carbohydrates  Reactome pathways data set
##   Gene.pathways.identifier Gene.organism.shortName
## 1            R-HSA-9033807              H. sapiens
## 2            R-HSA-9033658              H. sapiens
## 3            R-HSA-1430728              H. sapiens
## 4              R-HSA-71387              H. sapiens

Now we are seeing pathways for the ABO gene.

8.2 Add a new constraint

You can also add additional filters. Let’s look for a specifc pathway.

There are four parts of a constraint to add:

  1. path
    1. I got the path from the output columns but I could have figured out it from the data model.
  2. op
    1. Valid values: “=”, “!=”, “LOOKUP”, “ONE OF”, “NONE OF”, “>”, “<”, “>=”, “<=”, “LIKE”
  3. value
    1. What value I am filtering on.
  4. code
    1. Must be a letter not in use by the query already. Looking at the query output above we can see we only have one constraint, labelled ‘A’. Let’s use ‘B’ for our code.
newConstraint <- list(
  path=c("Gene.pathways.name"),
  op=c("="), 
  value=c("ABO blood group biosynthesis"), 
  code=c("B")
)

queryGenePath$where[[2]] <- newConstraint
queryGenePath$where
## [[1]]
## [[1]]$path
## [1] "Gene"
## 
## [[1]]$op
## [1] "LOOKUP"
## 
## [[1]]$code
## [1] "A"
## 
## [[1]]$editable
## [1] TRUE
## 
## [[1]]$switchable
## [1] FALSE
## 
## [[1]]$switched
## [1] "LOCKED"
## 
## [[1]]$value
## [1] "ABO"
## 
## 
## [[2]]
## [[2]]$path
## [1] "Gene.pathways.name"
## 
## [[2]]$op
## [1] "="
## 
## [[2]]$value
## [1] "ABO blood group biosynthesis"
## 
## [[2]]$code
## [1] "B"

Our new filter has been added successfully. Rerun the query and you see you only have one pathway,ABO blood group biosynthesis, returned.

resGenePath <- runQuery(im, queryGenePath)
resGenePath
##   Gene.primaryIdentifier Gene.symbol
## 1                     28         ABO
## 2            MGI:2135738         Abo
##                                                                                                                      Gene.name
## 1                                         ABO, alpha 1-3-N-acetylgalactosaminyltransferase and alpha 1-3-galactosyltransferase
## 2 ABO blood group (transferase A, alpha 1-3-N-acetylgalactosaminyltransferase, transferase B, alpha 1-3-galactosyltransferase)
##             Gene.pathways.name Gene.pathways.dataSets.name
## 1 ABO blood group biosynthesis  Reactome pathways data set
## 2 ABO blood group biosynthesis  Reactome pathways data set
##   Gene.pathways.identifier Gene.organism.shortName
## 1            R-HSA-9033807              H. sapiens
## 2            R-MMU-9033807             M. musculus

8.3 Add a column

You can also add additional columns to the output. For instance, is the Gene also involved in any disease? Let’s add this information.

Let’s see what we know about diseases.

9 {r add_column, warning=FALSE, message=FALSE} # model[which(model$type=="Gene"),] #

The Gene data type has an ‘Diseases’ reference of type ‘Disease’.

10 {r add_column2, warning=FALSE, message=FALSE} # model[which(model$type=="Disease"),] #

Disease has an attribute called “name”. Add Gene.diseases.name to the view. We’ll add it as the last column, we can see from above there are 7 other columns already so we’ll put it as #8:

# use setQuery function which will create an InterMineR-class query
queryGenePath.InterMineR = setQuery(
  inheritQuery = queryGenePath,
  select = c(queryGenePath$select, 
             "Gene.diseases.name")
  )

getSelect(queryGenePath.InterMineR)
## [1] "Gene.primaryIdentifier"      "Gene.symbol"                
## [3] "Gene.name"                   "Gene.pathways.name"         
## [5] "Gene.pathways.dataSets.name" "Gene.pathways.identifier"   
## [7] "Gene.organism.shortName"     "Gene.diseases.name"
#queryGenePath.InterMineR@select

# or assign new column directly to the existing list query
queryGenePath$select[[8]] <- "Gene.diseases.name"
queryGenePath$select
## [1] "Gene.primaryIdentifier"      "Gene.symbol"                
## [3] "Gene.name"                   "Gene.pathways.name"         
## [5] "Gene.pathways.dataSets.name" "Gene.pathways.identifier"   
## [7] "Gene.organism.shortName"     "Gene.diseases.name"
# run queries
resGenePath.InterMineR <- runQuery(im, queryGenePath.InterMineR)
resGenePath <- runQuery(im, queryGenePath)

all(resGenePath == resGenePath.InterMineR)
## [1] TRUE
head(resGenePath, 3)
##   Gene.primaryIdentifier Gene.symbol
## 1                     28         ABO
##                                                                              Gene.name
## 1 ABO, alpha 1-3-N-acetylgalactosaminyltransferase and alpha 1-3-galactosyltransferase
##             Gene.pathways.name Gene.pathways.dataSets.name
## 1 ABO blood group biosynthesis  Reactome pathways data set
##   Gene.pathways.identifier Gene.organism.shortName      Gene.diseases.name
## 1            R-HSA-9033807              H. sapiens BLOOD GROUP, ABO SYSTEM

NB: adding columns can result in changing the row count.

10.1 Change constraint logic

The constraintLogic, if not given, is ‘A and B’. We would now try to explicitly specify the constraintLogic. A and B corresponds to the ‘code’ for each constraint.

queryGenePath$constraintLogic <- "A and B"
queryGenePath$constraintLogic
## [1] "A and B"

Run the query again and see no change:

resGenePath <- runQuery(im, queryGenePath)
resGenePath
##   Gene.primaryIdentifier Gene.symbol
## 1                     28         ABO
##                                                                              Gene.name
## 1 ABO, alpha 1-3-N-acetylgalactosaminyltransferase and alpha 1-3-galactosyltransferase
##             Gene.pathways.name Gene.pathways.dataSets.name
## 1 ABO blood group biosynthesis  Reactome pathways data set
##   Gene.pathways.identifier Gene.organism.shortName      Gene.diseases.name
## 1            R-HSA-9033807              H. sapiens BLOOD GROUP, ABO SYSTEM

Change to be ‘A or B’ and see how the results change.

11 Recipes

11.1 Obtain the gene ontology (GO) terms associated with gene ABO

  • Start with the template Gene GO
queryGeneGO <- getTemplateQuery(im, "Gene_GO")
queryGeneGO
## $model
##      name 
## "genomic" 
## 
## $title
## [1] "Gene --> GO terms."
## 
## $description
## [1] "Search for GO annotations for a particular gene (or List of Genes)."
## 
## $select
## [1] "Gene.primaryIdentifier"                           
## [2] "Gene.symbol"                                      
## [3] "Gene.goAnnotation.ontologyTerm.identifier"        
## [4] "Gene.goAnnotation.ontologyTerm.name"              
## [5] "Gene.goAnnotation.ontologyTerm.namespace"         
## [6] "Gene.goAnnotation.evidence.code.code"             
## [7] "Gene.goAnnotation.ontologyTerm.parents.identifier"
## [8] "Gene.goAnnotation.ontologyTerm.parents.name"      
## [9] "Gene.goAnnotation.qualifier"                      
## 
## $name
## [1] "Gene_GO"
## 
## $comment
## [1] "Added 15NOV2010: ML"
## 
## $tags
## [1] "im:aspect:Function"      "im:aspect:Gene Ontology"
## [3] "im:aspect:Genomics"      "im:frontpage"           
## [5] "im:public"               "im:report"              
## 
## $rank
## [1] "4"
## 
## $authorized
## [1] FALSE
## 
## $orderBy
## $orderBy[[1]]
## Gene.primaryIdentifier 
##                  "ASC" 
## 
## 
## $where
## $where[[1]]
## $where[[1]]$path
## [1] "Gene"
## 
## $where[[1]]$op
## [1] "LOOKUP"
## 
## $where[[1]]$code
## [1] "A"
## 
## $where[[1]]$editable
## [1] TRUE
## 
## $where[[1]]$switchable
## [1] FALSE
## 
## $where[[1]]$switched
## [1] "LOCKED"
## 
## $where[[1]]$value
## [1] "PPARG"
## 
## $where[[1]]$extraValue
## [1] "H. sapiens"
  • Modify the view to display a compact view
queryGeneGO$select <- queryGeneGO$select[2:5]
queryGeneGO$select
## [1] "Gene.symbol"                              
## [2] "Gene.goAnnotation.ontologyTerm.identifier"
## [3] "Gene.goAnnotation.ontologyTerm.name"      
## [4] "Gene.goAnnotation.ontologyTerm.namespace"
  • Modify the constraints to look for gene ABO.
queryGeneGO$where[[1]][["value"]] <- "ABO"
queryGeneGO$where
## [[1]]
## [[1]]$path
## [1] "Gene"
## 
## [[1]]$op
## [1] "LOOKUP"
## 
## [[1]]$code
## [1] "A"
## 
## [[1]]$editable
## [1] TRUE
## 
## [[1]]$switchable
## [1] FALSE
## 
## [[1]]$switched
## [1] "LOCKED"
## 
## [[1]]$value
## [1] "ABO"
## 
## [[1]]$extraValue
## [1] "H. sapiens"
  • Run the query
resGeneGO <- runQuery(im, queryGeneGO )
head(resGeneGO)
##   Gene.symbol Gene.goAnnotation.ontologyTerm.identifier
## 1         ABO                                GO:0000139
## 2         ABO                                GO:0000166
## 3         ABO                                GO:0003823
## 4         ABO                                GO:0004380
## 5         ABO                                GO:0004381
## 6         ABO                                GO:0005576
##                                                Gene.goAnnotation.ontologyTerm.name
## 1                                                                   Golgi membrane
## 2                                                               nucleotide binding
## 3                                                                  antigen binding
## 4 glycoprotein-fucosylgalactoside alpha-N-acetylgalactosaminyltransferase activity
## 5                        fucosylgalactoside 3-alpha-galactosyltransferase activity
## 6                                                             extracellular region
##   Gene.goAnnotation.ontologyTerm.namespace
## 1                       cellular_component
## 2                       molecular_function
## 3                       molecular_function
## 4                       molecular_function
## 5                       molecular_function
## 6                       cellular_component

11.2 Obtain the genes associated with gene ontology (GO) term ‘metal ion binding’

  • Start with the template Gene GO
queryGOGene <- getTemplateQuery(im, "GOterm_Gene")
queryGOGene
## $model
##      name 
## "genomic" 
## 
## $title
## [1] "GO term --> Genes"
## 
## $description
## [1] "Search for Genes in a specified organism that are associated with a particular Gene Ontology (GO) annotation."
## 
## $select
## [1] "Gene.primaryIdentifier"                     
## [2] "Gene.symbol"                                
## [3] "Gene.name"                                  
## [4] "Gene.goAnnotation.ontologyTerm.identifier"  
## [5] "Gene.goAnnotation.ontologyTerm.name"        
## [6] "Gene.organism.shortName"                    
## [7] "Gene.goAnnotation.ontologyTerm.parents.name"
## 
## $constraintLogic
## [1] "B and C"
## 
## $name
## [1] "GOterm_Gene"
## 
## $comment
## [1] "Added 26OCT2010: ML"
## 
## $tags
## [1] "im:aspect:Function"      "im:aspect:Gene Ontology"
## [3] "im:aspect:Genomics"      "im:public"              
## [5] "im:report"              
## 
## $rank
## [1] "2"
## 
## $authorized
## [1] FALSE
## 
## $orderBy
## $orderBy[[1]]
## Gene.symbol 
##       "ASC" 
## 
## 
## $where
## $where[[1]]
## $where[[1]]$path
## [1] "Gene.organism.shortName"
## 
## $where[[1]]$op
## [1] "="
## 
## $where[[1]]$code
## [1] "B"
## 
## $where[[1]]$editable
## [1] FALSE
## 
## $where[[1]]$switchable
## [1] FALSE
## 
## $where[[1]]$switched
## [1] "LOCKED"
## 
## $where[[1]]$value
## [1] "H. sapiens"
## 
## 
## $where[[2]]
## $where[[2]]$path
## [1] "Gene.goAnnotation.ontologyTerm.parents.name"
## 
## $where[[2]]$op
## [1] "="
## 
## $where[[2]]$code
## [1] "C"
## 
## $where[[2]]$editable
## [1] TRUE
## 
## $where[[2]]$switchable
## [1] FALSE
## 
## $where[[2]]$switched
## [1] "LOCKED"
## 
## $where[[2]]$value
## [1] "DNA binding"
  • Modify the view to display a compact view
queryGOGene$select <- queryGOGene$select[2:5]
queryGOGene$select
## [1] "Gene.symbol"                              
## [2] "Gene.name"                                
## [3] "Gene.goAnnotation.ontologyTerm.identifier"
## [4] "Gene.goAnnotation.ontologyTerm.name"
  • Modify the constraints to look for GO term ‘metal ion binding’
queryGOGene$where[[1]]$value = "metal ion binding"
queryGOGene$where
## [[1]]
## [[1]]$path
## [1] "Gene.organism.shortName"
## 
## [[1]]$op
## [1] "="
## 
## [[1]]$code
## [1] "B"
## 
## [[1]]$editable
## [1] FALSE
## 
## [[1]]$switchable
## [1] FALSE
## 
## [[1]]$switched
## [1] "LOCKED"
## 
## [[1]]$value
## [1] "metal ion binding"
## 
## 
## [[2]]
## [[2]]$path
## [1] "Gene.goAnnotation.ontologyTerm.parents.name"
## 
## [[2]]$op
## [1] "="
## 
## [[2]]$code
## [1] "C"
## 
## [[2]]$editable
## [1] TRUE
## 
## [[2]]$switchable
## [1] FALSE
## 
## [[2]]$switched
## [1] "LOCKED"
## 
## [[2]]$value
## [1] "DNA binding"
  • Run the query
resGOGene <- runQuery(im, queryGOGene )
head(resGOGene)
## NULL

11.3 Find and plot the genes within 50000 base pairs of gene ABCA6

  • Start with the Gene_Location template, update to search for ABCA6 gene.
queryGeneLoc = getTemplateQuery(im, "Gene_Location")
queryGeneLoc$where[[2]][["value"]] = "ABCA6"
resGeneLoc= runQuery(im, queryGeneLoc)

resGeneLoc
##   Gene.primaryIdentifier Gene.secondaryIdentifier Gene.symbol
## 1                  23460          ENSG00000154262       ABCA6
##                                   Gene.name Gene.chromosome.primaryIdentifier
## 1 ATP binding cassette subfamily A member 6                                17
##   Gene.locations.start Gene.locations.end Gene.locations.strand
## 1             69062044           69141927                    -1

We’re going to use the output (gene location) as input for the next query.

  • Define a new query
# set constraints
constraints = setConstraints(
  paths = c(
    "Gene.chromosome.primaryIdentifier",
    "Gene.locations.start",
    "Gene.locations.end",
    "Gene.organism.name"
  ),
  operators = c(
    "=",
    ">=",
    "<=",
    "="
  ),
  values = list(
    resGeneLoc[1, "Gene.chromosome.primaryIdentifier"],
    as.character(as.numeric(resGeneLoc[1, "Gene.locations.start"])-50000),
    as.character(as.numeric(resGeneLoc[1, "Gene.locations.end"])+50000),
    "Homo sapiens"
  )
)

# set InterMineR-class query
queryNeighborGene = setQuery(
  select = c("Gene.primaryIdentifier", 
             "Gene.symbol",
             "Gene.chromosome.primaryIdentifier",
             "Gene.locations.start", 
             "Gene.locations.end", 
             "Gene.locations.strand"),
  where = constraints
)

summary(queryNeighborGene)
##                                path op        value code
## 1 Gene.chromosome.primaryIdentifier  =           17    A
## 2              Gene.locations.start >=     69012044    B
## 3                Gene.locations.end <=     69191927    C
## 4                Gene.organism.name  = Homo sapiens    D
  • Run the query
resNeighborGene <- runQuery(im, queryNeighborGene)
resNeighborGene
##   Gene.primaryIdentifier Gene.symbol Gene.chromosome.primaryIdentifier
## 1              100616316    MIR4524A                                17
## 2              100847008    MIR4524B                                17
## 3                  23460       ABCA6                                17
##   Gene.locations.start Gene.locations.end Gene.locations.strand
## 1             69099564           69099632                    -1
## 2             69099542           69099656                     1
## 3             69062044           69141927                    -1
  • Plot the genes
resNeighborGene$Gene.locations.strand[which(resNeighborGene$Gene.locations.strand==1)]="+"

resNeighborGene$Gene.locations.strand[which(resNeighborGene$Gene.locations.strand==-1)]="-"

gene.idx = which(nchar(resNeighborGene$Gene.symbol)==0)

resNeighborGene$Gene.symbol[gene.idx]=resNeighborGene$Gene.primaryIdentifier[gene.idx]
require(Gviz)
annTrack = AnnotationTrack(
  start=resNeighborGene$Gene.locations.start,
  end=resNeighborGene$Gene.locations.end,
  strand=resNeighborGene$Gene.locations.strand,
  chromosome=resNeighborGene$Gene.chromosome.primaryIdentifier[1],
  genome="GRCh38", 
  name="around ABCA6",
  id=resNeighborGene$Gene.symbol)

gtr <- GenomeAxisTrack()
itr <- IdeogramTrack(genome="hg38", chromosome="chr17")

plotTracks(list(gtr, itr, annTrack), shape="box", showFeatureId=TRUE, fontcolor="black")

12 System info

sessionInfo()
## R version 4.3.1 (2023-06-16)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.18-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=C                  LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: America/New_York
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] grid      stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
## [1] Gviz_1.46.0          GenomicRanges_1.54.0 GenomeInfoDb_1.38.0 
## [4] IRanges_2.36.0       S4Vectors_0.40.0     BiocGenerics_0.48.0 
## [7] InterMineR_1.24.0    BiocStyle_2.30.0    
## 
## loaded via a namespace (and not attached):
##   [1] RColorBrewer_1.1-3          rstudioapi_0.15.0          
##   [3] jsonlite_1.8.7              magrittr_2.0.3             
##   [5] magick_2.8.1                GenomicFeatures_1.54.0     
##   [7] rmarkdown_2.25              BiocIO_1.12.0              
##   [9] zlibbioc_1.48.0             vctrs_0.6.4                
##  [11] memoise_2.0.1               Rsamtools_2.18.0           
##  [13] RCurl_1.98-1.12             base64enc_0.1-3            
##  [15] htmltools_0.5.6.1           S4Arrays_1.2.0             
##  [17] progress_1.2.2              curl_5.1.0                 
##  [19] SparseArray_1.2.0           Formula_1.2-5              
##  [21] sass_0.4.7                  bslib_0.5.1                
##  [23] htmlwidgets_1.6.2           gsubfn_0.7                 
##  [25] cachem_1.0.8                GenomicAlignments_1.38.0   
##  [27] igraph_1.5.1                lifecycle_1.0.3            
##  [29] pkgconfig_2.0.3             Matrix_1.6-1.1             
##  [31] R6_2.5.1                    fastmap_1.1.1              
##  [33] GenomeInfoDbData_1.2.11     MatrixGenerics_1.14.0      
##  [35] digest_0.6.33               colorspace_2.1-0           
##  [37] AnnotationDbi_1.64.0        chron_2.3-61               
##  [39] Hmisc_5.1-1                 RSQLite_2.3.1              
##  [41] filelock_1.0.2              fansi_1.0.5                
##  [43] RJSONIO_1.3-1.8             httr_1.4.7                 
##  [45] abind_1.4-5                 compiler_4.3.1             
##  [47] bit64_4.0.5                 htmlTable_2.4.1            
##  [49] backports_1.4.1             BiocParallel_1.36.0        
##  [51] DBI_1.1.3                   biomaRt_2.58.0             
##  [53] rappdirs_0.3.3              DelayedArray_0.28.0        
##  [55] rjson_0.2.21                tools_4.3.1                
##  [57] foreign_0.8-85              nnet_7.3-19                
##  [59] glue_1.6.2                  restfulr_0.0.15            
##  [61] checkmate_2.2.0             cluster_2.1.4              
##  [63] generics_0.1.3              gtable_0.3.4               
##  [65] BSgenome_1.70.0             ensembldb_2.26.0           
##  [67] data.table_1.14.8           hms_1.1.3                  
##  [69] xml2_1.3.5                  utf8_1.2.4                 
##  [71] XVector_0.42.0              pillar_1.9.0               
##  [73] stringr_1.5.0               dplyr_1.1.3                
##  [75] BiocFileCache_2.10.0        lattice_0.22-5             
##  [77] deldir_1.0-9                rtracklayer_1.62.0         
##  [79] bit_4.0.5                   biovizBase_1.50.0          
##  [81] tidyselect_1.2.0            Biostrings_2.70.0          
##  [83] knitr_1.44                  gridExtra_2.3              
##  [85] bookdown_0.36               ProtGenerics_1.34.0        
##  [87] sqldf_0.4-11                SummarizedExperiment_1.32.0
##  [89] xfun_0.40                   Biobase_2.62.0             
##  [91] matrixStats_1.0.0           proto_1.0.0                
##  [93] stringi_1.7.12              lazyeval_0.2.2             
##  [95] yaml_2.3.7                  evaluate_0.22              
##  [97] codetools_0.2-19            interp_1.1-4               
##  [99] tibble_3.2.1                BiocManager_1.30.22        
## [101] cli_3.6.1                   rpart_4.1.21               
## [103] munsell_0.5.0               jquerylib_0.1.4            
## [105] Rcpp_1.0.11                 dichromat_2.0-0.1          
## [107] dbplyr_2.3.4                png_0.1-8                  
## [109] XML_3.99-0.14               parallel_4.3.1             
## [111] ggplot2_3.4.4               blob_1.2.4                 
## [113] prettyunits_1.2.0           latticeExtra_0.6-30        
## [115] jpeg_0.1-10                 AnnotationFilter_1.26.0    
## [117] bitops_1.0-7                VariantAnnotation_1.48.0   
## [119] scales_1.2.1                crayon_1.5.2               
## [121] rlang_1.1.1                 KEGGREST_1.42.0

13 Appendix

13.1 Visual way to derive the column name of a query view or the path name in a query constraint from the database webpage


The InterMine model could be accessed from the mine homepage by clicking the tab “QueryBuilder” and selecting the appropriate data type under “Select a Data Type to Begin a Query”:


Here we select Gene as the data type:


We could select Symbol and Chromosome->Primary Identifier by clicking Show on the right of them. Then click “Export XML” at the bottom right corner of the webpage:


The column names Gene.symbol and Gene.chromosome.primaryIdentifier are contained in the XML output: