Skip to content

Latest commit

 

History

History
1370 lines (1037 loc) · 73.5 KB

database.org

File metadata and controls

1370 lines (1037 loc) · 73.5 KB

Database Information

WARNING: This document contains information on the GN databases which will change over time. The GN database is currently MySQL based and, while efficient, contains a number of design choices we want to grow ‘out’ of. Especially with an eye on reproducibility we want to introduce versioning.

So do not treat the information in this document as a final way of accessing data. It is better to use the REST API.

The small test database (2GB)

The default install comes with a smaller database which includes a number of the BXD’s and the Human liver dataset (GSE9588).

GeneNetwork database

Estimated table sizes

select table_name,round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` from information_schema.TABLES where table_schema = “db_webqtl” order by data_length;

————————-————+

table_nameSize in MB

————————-————+

ProbeSetData59358.80
SnpAll15484.67
ProbeData22405.44
SnpPattern9177.05
ProbeSetSE14551.02
QuickSearch5972.86
ProbeSetXRef4532.89
LCorrRamin318506.53
ProbeSE6263.83
ProbeSet2880.21
Probe2150.30
GenoData3291.91
CeleraINFO_mm6989.80
pubmedsearch1032.50
ProbeXRef743.38
GeneRIF_BASIC448.54
BXDSnpPosition224.44
EnsemblProbe133.66
EnsemblProbeLocation105.49
Genbank37.71
TissueProbeSetData74.42
AccessLog42.38
GeneList34.11
Geno33.90
MachineAccessLog28.34
IndelAll22.42
PublishData22.54
TissueProbeSetXRef14.73
ProbeH213.26
GenoXRef22.83
TempData8.35
GeneList_rn35.54
GORef4.97
Phenotype6.50
temporary3.59
InfoFiles3.32
Publication3.42
Homologene5.69
Datasets2.31
GeneList_rn332.61
PublishSE4.71
GeneRIF2.18
Vlookup1.87
H22.18
PublishXRef2.18
NStrain4.80
IndelXRef2.91
Strain1.07
GeneMap_cuiyan0.51
user_collection0.30
CaseAttributeXRef0.44
StrainXRef0.56
GeneIDXRef0.77
Docs0.17
News0.17
ProbeSetFreeze0.22
GeneRIFXRef0.24
Sample0.06
login0.06
user0.04
TableFieldAnnotation0.05
DatasetMapInvestigator0.05
User0.04
ProbeFreeze0.06
TableComments0.02
Investigators0.02
DBList0.03
Tissue0.02
GeneChip0.01
GeneCategory0.01
SampleXRef0.01
InbredSet0.01
SnpAllele_to_be_deleted0.00
Organizations0.01
PublishFreeze0.00
GenoFreeze0.00
Chr_Length0.01
SnpSource0.00
AvgMethod0.00
Species0.00
Dataset_mbat0.00
TissueProbeFreeze0.00
EnsemblChip0.00
TissueProbeSetFreeze0.01
UserPrivilege0.00
CaseAttribute0.00
MappingMethod0.00
DBType0.00
InfoFilesUser_md50.00
GenoCode0.00
DatasetStatus0.00
GeneChipEnsemblXRef0.00
GenoSE0.00
user_openids0.00
roles_users0.00
role0.00
TempNULL

————————-————+ 97 rows in set, 1 warning (0.01 sec)

All *Data tables are large

User access

According to the meta data:

This table tracks access time and IP addresses. Used for logging in registered users and tracking cookies.

select * from AccessLog limit 5;

——-———————+—————-+

idaccesstimeip_address

——-———————+—————-+

121742003-10-28 02:17:41130.120.104.71
121732003-10-28 02:16:27130.120.104.71
32003-02-22 07:38:33192.117.159.1
42003-02-22 07:49:13192.117.159.1
52003-02-22 07:51:08192.117.159.1

——-———————+—————-+

select * from AccessLog order by accesstime desc limit 5; ——————————+—————+

idaccesstimeip_address

——————————+—————+

10257352016-02-08 14:23:29100.43.81.157
10257342016-02-08 13:54:28180.76.15.144
10257332016-02-08 13:43:3766.249.65.217
10257322016-02-08 13:39:5066.249.65.217
10257312016-02-08 13:15:4666.249.65.217

——————————+—————+

Quite a few trait page hits:

select count(*) from AccessLog;

———-

count(*)

———-

1025685

———-

show indexes from AccessLog; ———–————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+

TableNon_uniqueKey_nameSeq_in_indexColumn_nameCollationCardinalitySub_partPackedNullIndex_typeCommentIndex_comment

———–————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+

AccessLog0PRIMARY1idA1025685NULLNULLBTREE

———–————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+

This table is being used by both GN1 and GN2 from the trait pages!

grep -ir AccessLog *|grep -e "^gn1\|^gn2"|grep \.py|grep -v doc

gn1/web/webqtl/showTrait/ShowTraitPage.py: query = “SELECT count(id) FROM AccessLog WHERE ip_address = %s and \ gn1/web/webqtl/showTrait/ShowTraitPage.py: self.cursor.execute(“insert into AccessLog(accesstime,ip_address) values(Now(),%s)” ,user_ip) gn1/web/webqtl/textUI/cmdClass.py: query = “”“SELECT count(id) FROM AccessLog WHERE ip_address = %s AND UNIX_TIMESTAMP()-UNIX_TIMESTAMP(accesstime)<86400”“” gn1/web/webqtl/textUI/cmdClass.py: query = “”“INSERT INTO AccessLog(accesstime,ip_address) values(Now(),%s)”“” gn2/wqflask/wqflask/show_trait/show_trait_page.py: query = “SELECT count(id) FROM AccessLog WHERE ip_address = %s and \ gn2/wqflask/wqflask/show_trait/show_trait_page.py: self.cursor.execute(“insert into AccessLog(accesstime,ip_address) values(Now(),%s)”, user_ip)

When looking at the code in GN1 and GN2 it restricts the daily use of the trait data page (set to 1,000 - whoever reaches that?). Unlike mentioned in the schema description, this table does not keep track of cookies.

From the code it looks like GN2 uses a mixture of Redis and sqlalchemy to keep track of logged in sessions (see gn2/wqflask/wqflask/user_manager.py) and cookies through a user_uuid in model.py.

In gn2/wqflask/wqflask/templates/collections/view_anonymous.html it show_trait_page appears to be loaded (need to check).

AvgMethod

Probesetfreeze refers to AvgMethod

BXDSnPosition

Snp table (all snps)

Mapping in GN1 shows snps when you select a chromosome.

CaseAttribute(XRef)

Metadata

CeleralINFO_mm6

?

Chr_Length (/cross/BXD.json)

Default mm9, column for mm8

select * from Chr_Length;

NameSpeciesIdOrderIdLengthLength_mm8
111197195432197069962
212181748087181976762

Table should be merged with

Dataset_mbat

Menu for BXD (linkouts)

DatasetMapInvestigator

Arthur?

DataSets

Information/metadata

DatasetStatus

Arthur private/public

DBList and DBType

Hooked in API (URL encoding)

Docs

GN2 only (see menu bar)

Ensembl*

Probe information

(will be deprecated)

Genbank

Linkout and not important

GeneCategory

Not important. GeneWiki notes function classification.

Deprecate.

GeneChip

GeneIDXRef

Interspecies gene comparison

GeneList

Track info

Genlist_rn3(3)

Rat list

GeneMap_cuiyan

Link outs

GeneRIF

Wiki info (nightly updated from NCBI)

XRef should be foreign keys

Geno (genotype/marker/’marker’.json)

SNP or marker info

INFO:base.trait:.sql: retrieve_info: select Geno.Chr, Geno.Mb from Geno, Species where Species.Name = ‘mouse’ and Geno.Name = ‘rs3693478’ and Geno.SpeciesId = Species.Id

IdSpeciesIdNameMarker_NameChrMbSequenceSourcechr_numSource2Commentsused_by_geno_fileMb_mm8Chr_mm8
1101.001.69501.001.69514.678288GCCCTGCCCACCTCAGAGCAAGCTGCCACCCAGGAGTCCGTGTTTCAGGAGATGTGTGAGGAGGGCCTGCTGGAGGAGTGTGATGGTGAGGATGAGGCAGGCCGTGCCGCG[T/C]AGCCAGAGGCTGGTGATGGGACCACCGAGATCTCACCCACTGGTGCTGCTGATCCTGAGAAGAGGATGGAGAAGAAGACGGAGCAGCAGCACACCGGCGGCGGGAGAAAGCTGCTCGTAAGCTGCTCGTAAGCTACGGGTGCAGCAGGCTGCACTTAGGGCAGCCCGGCTTCAGCACCAAGAACTCTTCAGGCTGCATGGGATCAAGGCCCAGGTGGCCCGAAGGCTGGCAGAACTCGCACACGGGAGGGAGCAGCAGCGCATACAGCGACTGGCAGAGGCTGACAAGCCCCGAAGGCTGGGACGACTCAAGTACCAGGCTCCTGACATTGATGTGCAGCTCAGCTCTGAGCTGTCTGGCCCACTCAGGACACTGAAACCAGAAGGTCACATTCTCCAAGACAGGTTCAAGAGCTTCCAGAAGAGAAATATGATTGAGCCCCGAGAACGAGCCAAGTTCAAGCGCAAATAAAAAATGAAGTTGGTGGAGAAGCGGGCCTACCATGAGATTCAGTTGTAGCTGTGCAGATGTCGGAGCCCCGCCCCTCAATAAAGTTCTGTGACAAAAAAAAAAAAAAAAAAAGAAGAAGAAGAAGAAAAGGAAAAAAAAGAAGAAAAAGAAAAAAAAAGAAAAAAGAAAAAGAAAACACATCACTTGGCAAAACTCCATAGACTCTATGTGATTCATGTTTCAAACATGCACCTAGNF_SNP1GNFNULLNULL4.6782881

GenoCode

Belongs to someone else

GenoData

Allele info

GenoFreeze

Big menu (Freeze refers to menu)

GenoSE

SE standard err, not used

GenoXREF

Very important. Key links between Geno, GenoData

GORef

GO terms

H2

Heritability for probeset(?)

Homologene

Homology, not used much

InbredSet (/cross/BXD.info)

Group in menu

Indelall, SnpAll, SnpPattern, SnpSource

Indel Snp browser (variant browser Gn1)

Info*

Infra system PhP

Data Info button

Infosystem users has separate entries

Also Investigators, User, Organizations,

LCorrRamin3

Lit. Correlations Prof. Ramin

Login

GN2 login info

MachineAccessLog

Old

MappingMethod

GN1

News

GN2

NStrain

pheno publishfreeze (menu) xref (keys) xref links to publish (pubmed), phenotype, pubishdata geno genofreeze xref (keys) xref links to publish (pubmed), genotype, genodata probeset/expr. probesetfreeze xref (keys) xref links to publish (pubmed), probeset, probesetdata probe/expr. probefreeze xref (keys) xref links to publish (pubmed), probe, probedata

Each dataset has 3 values (real value (1), number of samples (2), stderr (3))

NStrain = number of phenotype samples

ProbesetFreeze contains all data, incl. metabolomic.

Phenotype

This table contains names, full descriptions, and short symbols for traits and phenotype used primarily in the Published Phenotypes databases.

Contains 10k rows, March 2016, of which 5000 are for the BXDs).

IdPre_publication_descriptionPost_publication_descriptionOriginal_descriptionUnitsPre_publication_abbreviationPost_publication_abbreviationLab_codeSubmitterOwnerAuthorized_Users

—-—————————–+———————————————————————————————————————-+————————————————————————————————————————————————————-+———————-+——————————+——————————-+———-+————-+——-+——————+

1NULLHippocampus weightOriginal post publication description: Hippocampus weightUnknownNULLHPCWTNULLrobwilliamsNULLrobwilliams
2NULLCerebellum weightOriginal post publication description: Cerebellum weightmgNULLCBLWTNULLrobwilliamsNULLrobwilliams
3NULLInterleukin 1 activity by peritoneal macrophages stimulated with 10 ug/ml lipopolysaccharide [units/100 ug protein]Original post publication description: Interleukin 1 activity by peritoneal macrophages stimulated with 10 ug/ml lipopolysaccharide [units/100 ug protein]units/100 ug proteinNULLIL1ActivityNULLrobwilliamsNULLrobwilliams
4NULLCentral nervous system, morphology: Cerebellum weight, whole, bilateral in adults of both sexes [mg]Original post publication description: Cerebellum weight [mg]mgNULLCBLWT2NULLrobwilliamsNULLrobwilliams
5NULLThe coat color of 79 BXD RI strainOriginal post publication description: The coat color of 79 BXD RI strainUnknownNULLCoatColorNULLrobwilliamsNULLrobwilliams

—-—————————–+———————————————————————————————————————-+————————————————————————————————————————————————————-+———————-+——————————+——————————-+———-+————-+——-+——————+ 5 rows in set (0.00 sec)

ProbeData

Table with fine-grained probe level Affymetrix data only. Contains 1 billion rows March 2016. This table may be deletable since it is only used by the Probe Table display in GN1. Not used in GN2 (double-check).

In comparison the “ProbeSetData” table contains more molecular assay data, including probe set data, RNA-seq data, proteomic data, and metabolomic data. 2.5 billion rows March 2016. In comparison, ProbeData contains data only for Affymetrix probe level data (e.g. Exon array probes and M430 probes).

“ProbeData.StrainId” should be “CaseId” or “SampleId”.

“ProbeData” should probably be “AssayData” or something more neutral.

select * from ProbeData limit 2; ——–———-+———+

IdStrainIdvalue

——–———-+———+

5036364211.6906
5036364311.4205

——–———-+———+ 2 rows in set (0.00 sec)

select count(*) from ProbeData limit 2; ———–

count(*)

———–

976753435

———– 1 row in set (0.00 sec)

ProbeSet

Comment: PLEASE CHANGE TABLE NAME and rework fields carefully. This is a terrible table but it works well (RWW March 2016). It is used in combination with the crucial TRAIT DATA and ANALYSIS pages in GN1 and GN2. It is also used by annotators using the UPDATE INFO AND DATA web form to correct and update annotation. It is used by Arthur to enter new annotation files and metadata for arrays, genes, proteins, metabolites. The main problem with this table is that it is doing too much work.

Initially (2003) this table contained only Affymetrix ProbeSet data for mouse (U74aV2 initially). Many other array platforms for different species were added. At least four other major categories of molecular assays have been added since about 2010.

  1. RNA-seq annotation and sequence data for transcripts using ENSEMBL identifiers or NCBI NM_XXXXX and NR_XXXXX type identifiers
  2. Protein and peptide annotation and sequence data (see BXD Liver Proteome data, SRM and SWATH type data) with identifiers such as “abcb10_q9ji39_t311” for SRM data and “LLGNMIVIVLGHHLGKDFTPAAQAA” for SWATH data where the latter is just the peptide fragment that has been quantified. Data first entered in 2015 for work by Rudi Aebersold and colleagues.
  3. Metabolite annotation and metadata (see BXD Liver Metabolome data) with identifiers that are usually Mass charge ratios such as “149.0970810_MZ”
  4. Epigenomic and methylome data (e.g. Human CANDLE Methylation data with identifiers such as “cg24523000”)

It would make good sense to break this table into four or more types of molecular assay metadata or annotation tables) (AssayRNA_Anno, AssayProtein_Anno, AssayMetabolite_Anno, AssayEpigenome_Anno, AssayMetagenome_Anno), since these assays will have many differences in annotation content compared to RNAs.

Some complex logic is used to update contents of this table when annotators modify and correct the information (for example, updating gene symbols). These features requested by Rob so that annotating one gene symbol in one species would annotate all gene symbols in the same species based on common NCBI GeneID number. For example, changing the gene alias for one ProbeSet.Id will changing the list of aliases in all instances with the same gene symbol.

If the ProbeSet.BlatSeq (or is this ProbSetTargetSeq) is identical between different ProbeSet.Ids then annotation is forced to be the same even if the symbol or geneID is different. This “feature” was implemented when we found many probe sets with identical sequence but different annotations and identifiers.

select count(*) from ProbeSet limit 5; ———-

count(*)

———-

4351030

———-

IdChipIdNameTargetIdSymboldescriptionChrMbaliasGeneIdGenbankIdSNPBlatSeqTargetSeqUniGeneIdStrand_ProbeStrand_GeneOMIMcommentsProbe_set_target_regionProbe_set_specificityProbe_set_BLAT_scoreProbe_set_Blat_Mb_startProbe_set_Blat_Mb_endProbe_set_strandProbe_set_Note_by_RWflagSymbol_Hdescription_Hchromosome_HMB_Halias_HGeneId_Hchr_numname_numProbe_Target_DescriptionRefSeq_TranscriptIdChr_mm8Mb_mm8Probe_set_Blat_Mb_start_mm8Probe_set_Blat_Mb_end_mm8HomoloGeneIDBiotype_ENSProteinIDProteinNameFlybase_IdHMDB_IDConfidenceChEBI_IDChEMBL_IDCAS_numberPubChem_IDChemSpider_IDUNII_IDEC_numberKEGG_IDMolecular_WeightNugowiki_IDTypeTissuePrimaryNameSecondaryNamesPeptideSequence

————–+———-+———-+——–+———————————————-+——+———–+———-+——–+———–+——+——————————————————————————————————————————————————————————+—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————+———–+————–+————-+——–+———-+————————-+———————–+———————-+————————-+———————–+——————+———————-+——+———-+—————+————–+——+———+———-+———+———-+————————–+———————+———+———–+—————————–+—————————+————–+————-+———–+————-+————+———+————+———-+———–+————+————+—————+———+———–+———+——————+————-+——+——–+————-+—————-+—————–+

7282193288_atNULLArpc2actin related protein 2/3 complex, subunit 2174.310961AK00877776709AI8358830CCGACTTCCTTAAGGTGCTCAACCGGACTGCTTGCTACTGGATAATCGTGAGGGATTCTCCATTTGGGTTCCATTTTGTACGAGTTTGGCAAATAACCTGCAGAAACGAGCTGTGCTTGCAAGGACTTGATAGTTCCTAATCCTTTTCCAAGCTGTTTGCTTTGCAATATGTccgacttccttaaggtgctcaaccgtnnnnnnccnannnnccnagaaaaaagaaatgaaaannnnnnnnnnnnnnnnnnnttcatcccgctaactcttgggaactgaggaggaagcgctgtcgaccgaagnntggactgcttgctactggataatcgtnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnntgagggattctccatttgggttccattttgtacgagtttggcaaataacctgcagaaacgagctgtgcttgcaaggacttgatagttcctaagaattanaanaaaaaaaanaanttccacttgatcaanttaattcccttttatttttcctccctcantccccttccttttccaagctgtttgctttgcaatatgtMm.337038+604224NULL8.4516974.31096174.31466NULLNULL3NULLNULLNULLNULLNULLNULL193288NULLXM_129773174.19759474.19759474.2012934187NULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULLNULL

————–+———-+———-+——–+———————————————-+——+———–+———-+——–+———–+——+——————————————————————————————————————————————————————————+—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————+———–+————–+————-+——–+———-+————————-+———————–+———————-+————————-+———————–+——————+———————-+——+———-+—————+————–+——+———+———-+———+———-+————————–+———————+———+———–+—————————–+—————————+————–+————-+———–+————-+————+———+————+———-+———–+————+————+—————+———+———–+———+——————+————-+——+——–+————-+—————-+—————–+ 2 rows in set (0.00 sec)

ProbeSetXRef (phenotypes/dataset_name.json)

For every probe set (read dataset measuring point):

select * from ProbeSetXRef;

ProbeSetFreezeIdProbeSetIdDataIdLocus_oldLRS_oldpValue_oldmeanseLocusLRSpValueadditiveh2
11212352823439389NULLNULLNULL6.7460707070707NULLrs623937210.96755935688940.5670.0448545966228878NULL
11212352723439388NULLNULLNULL6.19416161616162NULLrs1347693610.90756703927620.567-0.0358456732993988NULL

where ProbeSetFreezeId is the dataset (experiment). ProbesetId refers to the probe set information (measuring point). DataId points to the data point. The othe values are used for search.

It is used in search thus:

SELECT distinct ProbeSet.Name as TNAME, ProbeSetXRef.Mean as TMEAN, ProbeSetXRef.LRS as TLRS, ProbeSetXRef.PVALUE as TPVALUE, ProbeSet.Chr_num as TCHR_NUM, ProbeSet.Mb as TMB, ProbeSet.Symbol as TSYMBOL, ProbeSet.name_num as TNAME_NUM FROM ProbeSetXRef, ProbeSet WHERE ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSetXRef.ProbeSetFreezeId = 112 ORDER BY ProbeSet.symbol ASC limit 5;

TNAMETMEANTLRSTPVALUETCHR_NUMTMBTSYMBOLTNAME_NUM
1445618_at7.0567979797979813.54174527646160.17875.077895NULL1445618
1452452_at7.23230.49443611322520.00006097560975604211212.6694NULL1452452

ProbeSetData

Probedata - main molecular data. Probesets, metabolome,

Almost all important molecular assay data is in this table including probe set data, RNA-seq data, proteomic data, and metabolomic data. 2.5 billion rows March 2016. In comparison, ProbeData contains data only for Affymetrix probe level data (e.g. Exon array probes and M430 probes).

select count(*) from ProbeSetData limit 5; —————

count(*)

—————

2,510,566,472

—————

select * from ProbeSetData limit 5; —-———-+——-+

IdStrainIdvalue

—-———-+——-+

115.742
125.006
136.079
146.414
154.885

—-———-+——-+

show indexes from ProbeSetData; ————–————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+

TableNon_uniqueKey_nameSeq_in_indexColumn_nameCollationCardinalitySub_partPackedNullIndex_typeCommentIndex_comment

————–————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+

ProbeSetData0DataId1IdA34868978NULLNULLBTREE
ProbeSetData0DataId2StrainIdA2510566472NULLNULLBTREE

————–————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+

select * from Strain limit 5; —-———-+———-+———–+——–+——-+

IdNameName2SpeciesIdSymbolAlias

—-———-+———-+———–+——–+——-+

1B6D2F1B6D2F11NULLNULL
2C57BL/6JC57BL/6J1B6JNULL
3DBA/2JDBA/2J1D2JNULL
4BXD1BXD11NULLNULL
5BXD2BXD21NULLNULL

—-———-+———-+———–+——–+——-+

show indexes from Strain; ——–————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+

TableNon_uniqueKey_nameSeq_in_indexColumn_nameCollationCardinalitySub_partPackedNullIndex_typeCommentIndex_comment

——–————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+

Strain0PRIMARY1IdA14368NULLNULLBTREE
Strain0Name1NameA14368NULLNULLYESBTREE
Strain0Name2SpeciesIdA14368NULLNULLBTREE
Strain1Symbol1SymbolA14368NULLNULLYESBTREE

——–————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+

A typical query may look like

SELECT Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id FROM (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef) left join ProbeSetSE on (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId) WHERE ProbeSetFreeze.name = ‘B139_K_1206_M’ AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND ProbeSetXRef.DataId = ProbeSetData.Id AND ProbeSetData.StrainId = Strain.Id Order BY Strain.Name

——-——-+——-+———-+

NamevalueerrorId

——-——-+——-+———-+

SM00138.3NULL25309550
SM0012.7NULL25309520
SM00120.3NULL25309507
SM001125.8NULL25309511
SM0018.2NULL25309534

——-——-+——-+———-+ 5 rows in set (22.28 sec)

select * from ProbeSetFreeze limit 5; —-—————+——-+————-+———————————+———————————————+————————-+————+———–+——–+—————–+—————–+———–+

IdProbeFreezeIdAvgIDNameName2FullNameShortNameCreateTimeOrderListpublicconfidentialityAuthorisedUsersDataScale

—-—————+——-+————-+———————————+———————————————+————————-+————+———–+——–+—————–+—————–+———–+

131Br_U_0803_MBXDMicroArray_ProbeSet_August03UTHSC Brain mRNA U74Av2 (Aug03) MAS5Brain U74Av2 08/03 MAS52003-08-01NULL00NULLlog2
2101Br_U_0603_MBXDMicroArray_ProbeSet_June03UTHSC Brain mRNA U74Av2 (Jun03) MAS5Brain U74Av2 06/03 MAS52003-06-01NULL00NULLlog2
381Br_U_0303_MBXDMicroArray_ProbeSet_March03UTHSC Brain mRNA U74Av2 (Mar03) MAS5Brain U74Av2 03/03 MAS52003-03-01NULL00NULLlog2
451Br_U_0503_MBXDMicroArray_ProbeSet_May03UTHSC Brain mRNA U74Av2 (May03) MAS5Brain U74Av2 05/03 MAS52003-05-01NULL00NULLlog2
541HC_U_0303_MGNFMicroArray_ProbeSet_March03GNF Hematopoietic Cells U74Av2 (Mar03) MAS5GNF U74Av2 03/03 MAS52003-03-01NULL00NULLlog2

—-—————+——-+————-+———————————+———————————————+————————-+————+———–+——–+—————–+—————–+———–+

select * from ProbeSetXRef limit 5; ——————————+——–+————+——————–+————+——————-+———————+—————–+——————–+——–+———————-+——+

ProbeSetFreezeIdProbeSetIdDataIdLocus_oldLRS_oldpValue_oldmeanseLocusLRSpValueadditiveh2

——————————+——–+————+——————–+————+——————-+———————+—————–+——————–+——–+———————-+——+

11110.095.40013.39716278988940.1635.487942857142860.08525787814808819rs1348061912.5900699310480010.269-0.28515625NULL
122D15Mit18910.0420574643562010.4319.901657142857140.0374686634976217CEL-17_5089618210.59707379009410.304-0.11678333333333299NULL
133D5Mit1395.436785317427490.9937.839485714285710.0457583416912569rs134784996.09705327027540.9880.112957489878542NULL
144D1Mit5119.878152794807660.4838.3156285714285690.0470396593931327rs615437911.7748675511730990.286-0.157113725490196NULL
155D16H21S1610.1917238342644990.5289.193457142857140.0354801718293322rs419926510.9232633740162020.4680.11476470588235299NULL

——————————+——–+————+——————–+————+——————-+———————+—————–+——————–+——–+———————-+——+

Note that the following unlimited search is very slow:

select max(value) from ProbeSetData;

————

max(value)

————

26436006

———— 1 row in set (2 min 16.31 sec)

which is in some form is used in the search page, see the search code.

Improvements?

Suggestions on the schema page:

“StrainId” should be “CaseId” or “SampleId”.

“ProbeSetData” should probably be “AssayData” or something more neutral.

Comments

I think the ProbeSetData table should be generalized to a ‘phenotypes’ table with an ‘sample_id’ column and a ‘value’ column.

A new table ‘samples’ will link each sample against an ‘experiment’, an ‘individual’ and which in turn can link to a ‘strain’.

Experiment is here in a wide sense, GTex can be one - I don’t want to use dataset ;)

This means a (slight) reordering:

phenotypes: (id), sample_id, value samples: experiment_id, individual_id experiments: name, version individual: strain_id strains: species_id species: …

ProbeData is also interesting, because it has the same structure as ProbeSetData, but only contains microarrays. This tables should be one (when we clear up the cross-referencing) as they both contain phenotype values. Both are large tables.

PublishData is another phenotype table with values only which can be merged into that same table.

So we have phenotype data in 3 tables with exactly the same layout. There is also TissueProbeSet*, but we’ll ignore those for now. I think we should merge these into one and have the sample ref refer to the type of data (probeset, probe, metabolomics, whatever). These are all phenotype values and by having them split into different tables they won’t play well when looking for correlations.

ProbeSet contains the metadata on the probes and should (eventually) move into NoSQL. There is plenty redundancy in that table now.

I know it is going to be a pain to reorganize the database, but if we want to use it in the long run we are going to have to simplify it.

ProbeSetFreeze and ProbeFreeze (/dataset/name.json)

GN_SERVER: /dataset/HC_M2_0606_P.json

ProbesetFreeze contains DataSet information, such as name, fullname of datasets, as well as whether they are public and how the data is scaled:

select * from ProbeSetFreeze;

IdProbeFreezeIdAvgIDNameName2FullNameShortNameCreateTimeOrderListpublicconfidentialityAuthorisedUsersDataScale
112302HC_M2_0606_PHippocampus_M430_V2_BXD_PDNN_Jun06Hippocampus Consortium M430v2 (Jun06) PDNNHippocampus M430v2 BXD 06/06 PDNN2006-06-23NULL20NULLlog2

Another table contains a tissue reference and a back reference to the cross type:

select * from ProbeFreeze;

IdProbeFreezeIdChipIdTissueIdNameFullNameShortNameCreateTimeInbredSetId
303049Hippocampus Consortium M430v2 Probe (Jun06)2006-07-071

NOTE: these tables can probably be merged into one.

show indexes from ProbeSetFreeze; —————-————+———–+————–+————-+———–+————-+———-+——–+——+————+———+—————+

TableNon_uniqueKey_nameSeq_in_indexColumn_nameCollationCardinalitySub_partPackedNullIndex_typeCommentIndex_comment

—————-————+———–+————–+————-+———–+————-+———-+——–+——+————+———+—————+

ProbeSetFreeze0PRIMARY1IdA2NULLNULLBTREE
ProbeSetFreeze0FullName1FullNameA2NULLNULLBTREE
ProbeSetFreeze0Name1NameA2NULLNULLYESBTREE
ProbeSetFreeze1NameIndex1Name2A2NULLNULLBTREE

—————-————+———–+————–+————-+———–+————-+———-+——–+——+————+———+—————+

ProbeSetSE

select * from ProbeSetSE limit 5; ——–———-+———-+

DataIdStrainIderror

——–———-+———-+

110.681091
120.361151
130.364342
140.827588
150.303492

——–———-+———-+

Publication

Publication:

IdPubMed_IDAbstractTitlePagesMonthYear

Publishdata (all pheno)

One of three phenotype tables.

mysql> select * from PublishData limit 5; ——————-+——-+

IdStrainIdvalue

——————-+——-+

896635334929.6
896635335027.8
896635335126.6
896635335228.5
896635335324.6

——————-+——-+ 5 rows in set (0.25 sec)

See below for phenotype access.

QuickSearch

No longer used

role

empty

Sample*

No longer used

Species & Strain (should be sample)

select * from Species; —-———–+———————-+—————-+———————-+————————-+————+———+

IdSpeciesIdSpeciesNameNameMenuNameFullNameTaxonomyIdOrderId

—-———–+———————-+—————-+———————-+————————-+————+———+

11MousemouseMouseMus musculus1009030
22RatratRatRattus norvegicus1011640
33Arabidopsis thalianaarabidopsisArabidopsis thalianaArabidopsis thaliana370260
44HumanhumanHumanHomo sapiens960610
55BarleybarleyBarleyHordeum vulgare451370
66DrosophiladrosophilaDrosophilaDrosophila melanogaster722750
77Macaque monkeymacaque monkeyMacaque monkeyMacaca mulatta954420
88SoybeansoybeanSoybeanSoybean384780
99TomatotomatoTomatoTomato408190

—-———–+———————-+—————-+———————-+————————-+————+———+

InbredSet

Menu

TableComments

Metadata on DB

Temp*

User upload data

Tissue

Menu - 3rd level

TissueP*

Correlation tables

User collection

User selection - retained

UserPrivilege

Vlookup

Fetching Data

Search

What happens at the main search menu can be emulated with curl.

Search Mouse mRNA from HC_M2_0606_P dataset

curl "http://localhost:5003/search?species=mouse&group=BXD&ppocampus+mRNA&dataset=HC_M2_0606_P&search_terms_or=&search_terms_and=MEAN%3D%2815+16%29+LRS%3D%2823+46%29+&FormID=searchResult"

the first SQL query checks whether a dataset is confidential or not ayd fetches full name info

INFO:base.data_set:.sql: geno_mrna_confidentiality: u’SELECT Id, Name, FullName, confidentiality,AuthorisedUsers FROM ProbeSetFreeze WHERE Name = “HC_M2_0606_P”’

The following is executed once per search:

INFO:db.call:.sql: retrieve_other_names: SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.FullName, ProbeSetFreeze.ShortName, ProbeSetFreeze.DataScale, Tissue.Name FROM ProbeSetFreeze, ProbeFreeze, Tissue WHERE ProbeSetFreeze.public > 0 AND ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND ProbeFreeze.TissueId = Tissue.Id AND (ProbeSetFreeze.Name = ‘HC_M2_0606_P’ OR ProbeSetFreeze.FullName = ‘HC_M2_0606_P’ OR ProbeSetFreeze.ShortName = ‘HC_M2_0606_P’)

INFO:db.call:.sql: (112, ‘HC_M2_0606_P’, ‘Hippocampus Consortium M430v2 (Jun06) PDNN’, ‘Hippocampus M430v2 BXD 06/06 PDNN’, ‘log2’, ‘Hippocampus mRNA’)

INFO:db.call:.sql: __init__: SELECT InbredSet.Name, InbredSet.Id FROM InbredSet, ProbeSetFreeze, ProbeFreeze WHERE ProbeFreeze.InbredSetId = InbredSet.Id AND ProbeFreeze.Id = ProbeSetFreeze.ProbeFreezeId AND ProbeSetFreeze.Name = “HC_M2_0606_P”

INFO:db.call:.sql: (‘BXD’, 1)

The actual search is

SELECT distinct ProbeSet.Name as TNAME, 0 as thistable, ProbeSetXRef.Mean as TMEAN, ProbeSetXRef.LRS as TLRS, ProbeSetXRef.PVALUE as TPVALUE, ProbeSet.Chr_num as TCHR_NUM, ProbeSet.Mb as TMB, ProbeSet.Symbol as TSYMBOL, ProbeSet.name_num as TNAME_NUM FROM ProbeSetXRef, ProbeSet WHERE ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSetXRef.ProbeSetFreezeId = 112 ORDER BY ProbeSet.symbol ASC limit 5;

INFO:base.species:.sql: __init__: Select Chr_Length.Name, Chr_Length.OrderId, Length from Chr_Length, InbredSet where Chr_Length.SpeciesId = InbredSet.SpeciesId AND InbredSet.Name = ‘BXD’ Order by OrderId

And the following are executed for every trait:

INFO:wqflask.do_search:.sql: execute: SELECT distinct ProbeSet.Name as TNAME, 0 as thistable, ProbeSetXRef.Mean as TMEAN, ProbeSetXRef.LRS as TLRS, ProbeSetXRef.PVALUE as TPVALUE, ProbeSet.Chr_num as TCHR_NUM, ProbeSet.Mb as TMB, ProbeSet.Symbol as TSYMBOL, ProbeSet.name_num as TNAME_NUM FROM ProbeSetXRef, ProbeSet WHERE (( ProbeSetXRef.mean > 15.0 and ProbeSetXRef.mean < 16.0 )AND( ProbeSetXRef.LRS > 23.0 and ProbeSetXRef.LRS < 46.0 )) and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSetXRef.ProbeSetFreezeId = 112 ORDER BY ProbeSet.symbol ASC

INFO:base.trait:.sql: retrieve_info: SELECT ProbeSet.name, ProbeSet.symbol, ProbeSet.description, ProbeSet.probe_target_description, ProbeSet.chr, ProbeSet.mb, ProbeSet.alias, ProbeSet.geneid, ProbeSet.genbankid, ProbeSet.unigeneid, ProbeSet.omim, ProbeSet.refseq_transcriptid, ProbeSet.blatseq, ProbeSet.targetseq, ProbeSet.chipid, ProbeSet.comments, ProbeSet.strand_probe, ProbeSet.strand_gene, ProbeSet.probe_set_target_region, ProbeSet.probe_set_specificity, ProbeSet.probe_set_blat_score, ProbeSet.probe_set_blat_mb_start, ProbeSet.probe_set_blat_mb_end, ProbeSet.probe_set_strand, ProbeSet.probe_set_note_by_rw, ProbeSet.flag

FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSetFreeze.Name = ‘HC_M2_0606_P’ AND ProbeSet.Name = ‘1443823_s_at’

INFO:base.trait:.sql: retrieve_info: SELECT HomologeneId FROM Homologene, Species, InbredSet WHERE Homologene.GeneId =98660 AND InbredSet.Name = ‘BXD’ AND InbredSet.SpeciesId = Species.Id AND Species.TaxonomyId = Homologene.TaxonomyId

INFO:base.trait:.sql: retrieve_info: SELECT ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean, ProbeSetXRef.additive FROM ProbeSetXRef, ProbeSet WHERE ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSet.Name = “1443823_s_at” AND ProbeSetXRef.ProbeSetFreezeId =112

INFO:base.trait:.sql: retrieve_info: select Geno.Chr, Geno.Mb from Geno, Species where Species.Name = ‘mouse’ and Geno.Name = ‘NES13033186’ and Geno.SpeciesId = Species.Id

and finally mean and chromosome positions are fetched a second time for every trait with

INFO:base.data_set:.sql: get_trait_info: select ProbeSetXRef.mean from ProbeSetXRef, ProbeSet where ProbeSetXRef.ProbeSetFreezeId = 112 and ProbeSet.Id = ProbeSetXRef.ProbeSetId and ProbeSet.Name = ‘1443823_s_at’

INFO:base.data_set:.sql: get_trait_info: select Geno.Chr, Geno.Mb from Geno, Species where Species.Name = ‘mouse’ and Geno.Name = ‘NES13033186’ and Geno.SpeciesId = Species.Id

(that is a bug!).

Fetch phenotype information

Through the trait page

When hitting the trait page, e.g.

curl “http://localhost:5003/show_trait?trait_id=1443823_s_aet=HC_M2_0606_P”

First the BXD’s are queried with

DEBUG:base.data_set:.get_samplelist: Sample list: : [‘BXD1’, ‘BXD2’, ‘BXD5’, …

main probeset info (trait) is retrieved with

SELECT ProbeSet.name, ProbeSet.symbol, ProbeSet.description, ProbeSet.probe_target_description, ProbeSet.chr, ProbeSet.mb, ProbeSet.alias, ProbeSet.geneid, ProbeSet.genbankid, ProbeSet.unigeneid, ProbeSet.omim, ProbeSet.refseq_transcriptid, ProbeSet.blatseq, ProbeSet.targetseq, ProbeSet.chipid, ProbeSet.comments, ProbeSet.strand_probe, ProbeSet.strand_gene, ProbeSet.probe_set_target_region, ProbeSet.probe_set_specificity, ProbeSet.probe_set_blat_score, ProbeSet.probe_set_blat_mb_start, ProbeSet.probe_set_blat_mb_end, ProbeSet.probe_set_strand, ProbeSet.probe_set_note_by_rw, ProbeSet.flag FROM ProbeSet, ProbeSetFreeze, ProbeSetXRef WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSetFreeze.Name = ‘HC_M2_0606_P’ AND ProbeSet.Name = ‘1443823_s_at’

Followed by

INFO:base.trait:.sql: retrieve_info: SELECT ProbeSetXRef.Locus, ProbeSetXRef.LRS, ProbeSetXRef.pValue, ProbeSetXRef.mean, ProbeSetXRef.additive FROM ProbeSetXRef, ProbeSet WHERE ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSet.Name = “1443823_s_at” AND ProbeSetXRef.ProbeSetFreezeId =112

LocusLRSpValuemeanadditive
NES1303318635.4663240745420.0000090000000000367615.0551313131313-0.16750405405405402

Then the interesting bit, the sample data is fetched with

INFO:base.data_set:.sql: retrieve_sample_data: SELECT Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id, Strain.Name2 FROM (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef) left join ProbeSetSE on (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId) WHERE ProbeSet.Name = ‘1443823_s_at’ AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND ProbeSetFreeze.Name = ‘HC_M2_0606_P’ AND ProbeSetXRef.DataId = ProbeSetData.Id AND ProbeSetData.StrainId = Strain.Id Order BY Strain.Name

| BXD12 | 15.192 | NULL | 23422417 | BXD12 | etc.
NamevalueerrorIdName2
129S1/SvImJ14.552NULL23422417129S1/SvImJ
A/J14.34NULL23422417A/J
AKR/J14.338NULL23422417AKR/J
B6D2F115.251NULL23422417B6D2F1
BALB/cByJ14.164NULL23422417BALB/cByJ
BALB/cJ14.563NULL23422417BALB/cJ
BXD115.198NULL23422417BXD1
BXD1115.084NULL23422417BXD11

Then some repeated queries and this fetchest the nearest SNP

INFO:wqflask.show_trait.show_trait:.sql: get_nearest_marker: SELECT Geno.Name FROM Geno, GenoXRef, GenoFreeze WHERE Geno.Chr = ‘1’ AND GenoXRef.GenoId = Geno.Id AND GenoFreeze.Id = GenoXRef.GenoFreezeId AND GenoFreeze.Name = ‘BXDGeno’ ORDER BY ABS( Geno.Mb - 173.149434) limit 1;

Name
NES13033186

Digging deeper

To get at phenotype data ProbeSetData is the main table (almost all important molecular assay data is in this table including probe set data, RNA-seq data, proteomic data, and metabolomic data. 2.5 billion rows March 2016)

select count(*) from ProbeSetData limit 5; —————

count(*)

—————

2,510,566,472

—————

select * from ProbeSetData limit 5; —-———-+——-+

IdStrainIdvalue

—-———-+——-+

115.742
125.006
136.079
146.414
154.885

—-———-+——-+

This table is used in

wqflask/base/do_search.py
wqflask/base/data_set.py
wqflask/utility/AJAX_table.py
wqflask/wqflask/correlation/show_corr_results.py

In there we find ‘ProbeSetData.Id = ProbeSetXRef.dataId’.

select * from ProbeSetXRef limit 5; ——————————+——–+————+——————–+————+——————-+———————+—————–+——————–+——–+———————-+——+

ProbeSetFreezeIdProbeSetIdDataIdLocus_oldLRS_oldpValue_oldmeanseLocusLRSpValueadditiveh2

——————————+——–+————+——————–+————+——————-+———————+—————–+——————–+——–+———————-+——+

11110.095.40013.39716278988940.1635.487942857142860.08525787814808819rs1348061912.5900699310480010.269-0.28515625NULL
122D15Mit18910.0420574643562010.4319.901657142857140.0374686634976217CEL-17_5089618210.59707379009410.304-0.11678333333333299NULL
133D5Mit1395.436785317427490.9937.839485714285710.0457583416912569rs134784996.09705327027540.9880.112957489878542NULL
144D1Mit5119.878152794807660.4838.3156285714285690.0470396593931327rs615437911.7748675511730990.286-0.157113725490196NULL
155D16H21S1610.1917238342644990.5289.193457142857140.0354801718293322rs419926510.9232633740162020.4680.11476470588235299NULL

——————————+——–+————+——————–+————+——————-+———————+—————–+——————–+——–+———————-+——+

i.e., for Strain Id 1 (DataId) 1, the locus ‘10.095.400’ has a phenotype value of 5.742.

Interestingly ProbeData and PublishData have the same layout as ProbeSetData. ProbeData is only in use for Affy assays - and not used for computations. PublishData contains trait values. ProbeSetData.id matches ProbeSetXRef.DataId while PublishData.id matches PublishXRef.DataId.

select * from PublishXRef limit 3; ——-————-+————-+—————+———+—————-+——————+———–+———-+——————————————————-+

IdInbredSetIdPhenotypeIdPublicationIdDataIdLocusLRSadditiveSequencecomments

——-————-+————-+—————+———+—————-+——————+———–+———-+——————————————————-+

100018118966353D2Mit510.18351644706-1.208751
1000172538966813D7Mit25UT9.85534330983917-2.868751
1000143818966947CEL-6_5708252411.7119505898121-23.288751elissa modified Abstract at Tue Jun 7 11:38:00 2005

——-————-+————-+—————+———+—————-+——————+———–+———-+——————————————————-+ 3 rows in set (0.00 sec)

ties the trait data (PublishData) with the inbredsetid (matching PublishFreeze.InbredSetId), locus and publication.

select * from PublishFreeze -> ; —-————+————————–+————-+————+——–+————-+—————–+—————–+

IdNameFullNameShortNameCreateTimepublicInbredSetIdconfidentialityAuthorisedUsers

—-————+————————–+————-+————+——–+————-+—————–+—————–+

1BXDPublishBXD Published PhenotypesBXDPublish2004-07-17210NULL
18HLCPublishHLC Published PhenotypesHLC Publish2012-02-202340NULL

—-————+————————–+————-+————+——–+————-+—————–+—————–+ 2 rows in set (0.02 sec)

which gives us the datasets.

GeneNetwork1 has a limited REST interface, if you do

curl "http://robot.genenetwork.org/webqtl/main.py?cmd=get&probeset=1443823_s_at&db=HC_M2_0606_P"

we get

ProbeSetID      B6D2F1  C57BL/6J        DBA/2J  BXD1    BXD2    BXD5    BXD6   BXD8     BXD9    BXD11   BXD12   BXD13   BXD15   BXD16   BXD19   BXD20   BXD21  BXD22    BXD23   BXD24   BXD27   BXD28   BXD29   BXD31   BXD32   BXD33   BXD34  BXD38    BXD39   BXD40   BXD42   BXD67   BXD68   BXD43   BXD44   BXD45   BXD48  BXD50    BXD51   BXD55   BXD60   BXD61   BXD62   BXD63   BXD64   BXD65   BXD66  BXD69    BXD70   BXD73   BXD74   BXD75   BXD76   BXD77   BXD79   BXD73a  BXD83  BXD84    BXD85   BXD86   BXD87   BXD89   BXD90   BXD65b  BXD93   BXD94   A/J    AKR/J    C3H/HeJ C57BL/6ByJ      CXB1    CXB2    CXB3    CXB4    CXB5    CXB6   CXB7     CXB8    CXB9    CXB10   CXB11   CXB12   CXB13   BXD48a  129S1/SvImJ    BALB/cJ  BALB/cByJ       LG/J    NOD/ShiLtJ      PWD/PhJ BXD65a  BXD98   BXD99  CAST/EiJ KK/HlJ  WSB/EiJ NZO/HlLtJ       PWK/PhJ D2B6F1
1443823_s_at    15.251  15.626  14.716  15.198  14.918  15.057  15.232  14.968 14.87    15.084  15.192  14.924  15.343  15.226  15.364  15.36   14.792  14.908 15.344   14.948  15.08   15.021  15.176  15.14   14.796  15.443  14.636  14.921 15.22    15.62   14.816  15.39   15.428  14.982  15.05   15.13   14.722  14.636 15.242   15.527  14.825  14.416  15.125  15.362  15.226  15.176  15.328  14.895 15.141   15.634  14.922  14.764  15.122  15.448  15.398  15.089  14.765  15.234 15.302   14.774  14.979  15.212  15.29   15.012  15.041  15.448  14.34   14.338 14.809   15.046  14.816  15.232  14.933  15.255  15.21   14.766  14.8    15.506 15.749   15.274  15.599  15.673  14.651  14.692  14.552  14.563  14.164  14.546 15.044   14.695  15.162  14.772  14.645  15.493  14.75   14.786  15.003  15.148 15.221

(see https://github.com/genenetwork/gn_server/blob/master/doc/API.md for the latest REST API).

getTraitData is defined in the file web/webqtl/textUI/cmdClass.py. probe is None, so the code at line 199 is run

query = “SELECT Strain.Name, %sData.value from %sData, Strain, %s, %sXRef WHERE %s.Name = ‘%s’ and %sXRef.%sId = %s.Id and %sXRef.%sFreezeId = %d and %sXRef.DataId = %sData.Id and %sData.StrainId = Strain.Id order by Strain.Id” % (prefix, prefix, prefix, prefix, prefix, probeset,prefix, prefix, prefix, prefix, prefix, dbId, prefix, prefix, prefix)

where prefix is ProbeSet (one presumes). So, let’s see if we can do this by hand

SELECT Strain.Name, ProbeSetData.value from ProbeSetData, Strain, ProbeSet, ProbeSetXRef WHERE ProbeSet.Name = ‘1443823_s_at’ and ProbeSetXRef.ProbeSetId = ProbeSet.Id and ProbeSetXRef.ProbeSetFreezeId = $dbid and ProbeSetXRef.DataId = ProbeSetData.Id and ProbeSetData.StrainId = Strain.Id ORDER BY Strain.Id

The $dbid is listed in the ProbeSetFreeze table,

SELECT ProbeFreezeId,Name FROM ProbeSetFreeze WHERE Name=’HC_M2_0606_P’ limit 5;

—————————–+

ProbeFreezeIdName

—————————–+

30HC_M2_0606_P

—————————–+

select id,name from ProbeSet WHERE Name = ‘1443823_s_at’ limit 5; ——–————–+

idname

——–————–+

1065561443823_s_at

——–————–+

So

query = “SELECT Strain.Name, %sData.value from %sData, Strain, %s, %sXRef WHERE %s.Name = ‘%s’ and %sXRef.%sId = %s.Id and %sXRef.%sFreezeId = %d and %sXRef.DataId = %sData.Id and %sData.StrainId = Strain.Id order by Strain.Id” % (prefix, prefix, prefix, prefix, prefix, probeset,prefix, prefix, prefix, prefix, prefix, dbId, prefix, prefix, prefix)

CORRECT NAME:

SELECT Strain.Name, ProbeSetData.value from ProbeSetData, Strain, ProbeSet, ProbeSetXRef WHERE ProbeSet.Name = ‘at_probe’ and ProbeSetXRef.ProbeSetId = ProbeSet.Id and ProbeSetXRef.ProbeSetFreezeId = dbid and ProbeSetXRef.DataId = ProbeSetData.Id and ProbeSetData.StrainId = Strain.Id order by Strain.Id

select * from ProbeSetXRef WHERE probesetfreezeid=30 limit 5; ——————————+——–+————+——————–+————+——————–+——————–+—————–+——————–+——–+——————-+——+

ProbeSetFreezeIdProbeSetIdDataIdLocus_oldLRS_oldpValue_oldmeanseLocusLRSpValueadditiveh2

——————————+——–+————+——————–+————+——————–+——————–+—————–+——————–+——–+——————-+——+

30144596201.059.3507.17531520780695950.96130.06461.79763935596594rs134758917.17531520780692040.9734.71778125NULL
302445963D4Mit1567.589442929432850.724232.383285714286029.00278909374791CEL-4_1187514237.575134354262180.79325.2660951417004NULL
303445964D1Mit1349.7660654978268190.73747.2061.58413526287766mCV234310079.766065497826770.797-4.82405952380952NULL
304445965D1Mit15518.00458291572410.033132.292485714286024.37799472291842rs368994717.93650684062860.049-16.945619047619NULL
305445966D5Mit1979.510689026278230.476271.3099714285717.4294268316065395rs623937210.42149743166010.41-25.6148045454546NULL

——————————+——–+————+——————–+————+——————–+——————–+—————–+——————–+——–+——————-+——+

So, apparently ProbeSetFreezeID points to the database identifier in ProbeSetFreeze which has the name of the ‘DB’. OK, that kinda makes sense now. Meanwhile Probeset.name points to the phenotype name.

ProbeSetXRef binds these tables together. Finally there is the data in

select * from ProbeSetData limit 5; —-———-+——-+

IdStrainIdvalue

—-———-+——-+

115.742
125.006
136.079
146.414
154.885

—-———-+——-+ 5 rows in set (0.00 sec)

linked by ProbeSetXRef.dataid.

For PublishData:

List datasets for BXD (InbredSetId=1):

select * from PublishXRef where InbredSetId=1 limit 3; ——-————-+————-+—————+———+———–+——————+——————+———-+——————————————————————————–+

IdInbredSetIdPhenotypeIdPublicationIdDataIdLocusLRSadditiveSequencecomments

——-————-+————-+—————+———+———–+——————+——————+———-+——————————————————————————–+

10001141168967043rs825351613.49749141580392.394444444444441robwilliams modified post_publication_description at Mon Jul 30 14:58:10 2012
100021101168967044rs366606922.00426921516292.081785714285721robwilliams modified phenotype at Thu Oct 28 21:43:28 2010
100031151168967045D18Mit415.592916329334319.08823529411761robwilliams modified phenotype at Mon May 23 20:52:19 2011

——-————-+————-+—————+———+———–+——————+——————+———-+——————————————————————————–+

where ID is the ‘record’ or, effectively, dataset.

select distinct(publicationid) from PublishXRef where InbredSetId=1 limit 3; —————

publicationid

—————

116
117
118

—————

select distinct PublishXRef.id,publicationid,phenotypeid,Phenotype.post_publication_description from PublishXRef,Phenotype where InbredSetId=1 and phenotypeid=Phenotype.id limit 3; ——-—————+————-+—————————————————————————————————————————-+

idpublicationidphenotypeidpost_publication_description

——-—————+————-+—————————————————————————————————————————-+

100011164Central nervous system, morphology: Cerebellum weight [mg]
1000211610Central nervous system, morphology: Cerebellum weight after adjustment for covariance with brain size [mg]
1000311615Central nervous system, morphology: Brain weight, male and female adult average, unadjusted for body weight, age, sex [mg]

——-—————+————-+—————————————————————————————————————————-+

The id field is the same that is used in the GN2 web interface and the PublicationID ties the datasets together.

To list trait values:

SELECT Strain.Name, PublishData.id, PublishData.value from (Strain,PublishData, PublishXRef) Where PublishData.StrainId = Strain.id limit 3;

—————+——-+

Nameidvalue

—————+——-+

CXB1896635329.6
CXB1896635329.6
CXB1896635329.6

—————+——-+

here id should match dataid again:

SELECT Strain.Name, PublishData.id, PublishData.value from (Strain,PublishData, PublishXRef) Where PublishData.StrainId = Strain.id and PublishXRef.dataid=8967043 and PublishXRef.dataid=PublishData.id limit 3; —————+——-+

Nameidvalue

—————+——-+

BXD1896704361.4
BXD2896704349
BXD5896704362.5

—————+——-+

Datasets

The REST API aims to present a unified interface for genotype and phenotype data. Phenotype datasets appear in two major forms in the database and we want to present them as one resource.

Dataset names are defined in ProbeSetFreeze.name and Published.id -> publication (we’ll ignore the probe dataset that uses ProbeFreeze.name). These tables should be meshed. It looks like the ids are non-overlapping with the publish record IDs starting at 10,001 (someone has been smart, though it sets the limit of probesets now to 10,000).

The datasets are organized differently in these tables. All published BXD data is grouped on BXDpublished with the publications as ‘datasets’. So, that is how we list them in the REST API.

To fetch all the datasets we first list ProbeSetFreeze entries. Then we list the Published entries.

Fetch genotype information

SNPs

The SNP count info for the BXD is calculated like this

while startMb<endMb:
    snp_count = g.db.execute("""
            select
                    count(*) from BXDSnpPosition
            where
                    Chr = '%s' AND Mb >= %2.6f AND Mb < %2.6f AND
                    StrainId1 = %d AND StrainId2 = %d
            """ % (chrName, startMb, startMb+stepMb, strainId1, strainId2)).fetchone()[0]
    SNPCounts.append(snp_count)
    startMb += stepMb

select * from BXDSnpPosition limit 5; —————–+———–+———-+

ChrStrainId1StrainId2Mb

—————–+———–+———-+

1230.002477
1230.002592
1230.00283
1230.002994
1230.003299

—————–+———–+———-+

Other SNP tables containing

select * from SnpSource limit 5; Empty set (0.00 sec)

select * from SnpAll limit 5; Empty set (0.00 sec)

mysql> select * from SnpAll limit 5; Empty set (0.00 sec)

mysql> select * from SnpPattern limit 5; Empty set (0.00 sec)

mysql> select * from SnpSource limit 5; Empty set (0.00 sec)

Hmmm. This is the test database. Then there are the plink files and VCF files.