Skip to content

Commit d668447

Browse files
committed
Add proof of concept fact search of sample type
1 parent 267b85f commit d668447

5 files changed

Lines changed: 129 additions & 35 deletions

File tree

client/src/components/SampleList.vue

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { mapState } from "vuex";
2+
import { mapState, mapMutations } from "vuex";
33
44
export default {
55
name: "SampleList",
@@ -10,9 +10,19 @@ export default {
1010
}
1111
},
1212
computed: {
13-
...mapState(["meta"])
13+
...mapState(["meta", "selectedSampleType"]),
14+
filteredMeta() {
15+
if (!this.selectedSampleType) {
16+
return this.meta;
17+
} else {
18+
return this.meta.filter(
19+
meta => meta.material === this.selectedSampleType
20+
);
21+
}
22+
}
1423
},
1524
methods: {
25+
...mapMutations(["setSelectedSampleType"]),
1626
getPorjectName(sample) {
1727
return sample.name;
1828
},
@@ -73,18 +83,29 @@ export default {
7383
<v-checkbox
7484
:value="!!selectedSamples.length"
7585
:indeterminate="
76-
!!selectedSamples.length &&
77-
selectedSamples.length !== this.meta.length
86+
!!selectedSamples.length && selectedSamples.length !== meta.length
7887
"
7988
@change="checkAll($event)"
8089
/>
8190
</v-list-tile-action>
8291
</v-list-tile>
8392
</v-list>
93+
<v-expand-transition>
94+
<v-flex v-if="selectedSampleType" shrink>
95+
<v-chip
96+
small
97+
close
98+
dark
99+
color="teal darken-1"
100+
@input="setSelectedSampleType(null)"
101+
>{{ selectedSampleType }}</v-chip
102+
>
103+
</v-flex>
104+
</v-expand-transition>
84105
<v-list dense>
85106
<v-list-tile
86107
class="hover-show-parent"
87-
v-for="sample in this.meta"
108+
v-for="sample in filteredMeta"
88109
:key="sample['taxon_oid']"
89110
:class="{ selected: selectedSamples.indexOf(sample) !== -1 }"
90111
v-on="sample.source === 'LLNL' ? { click: () => 123 } : {}"

client/src/components/SamplesLocation.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ export default {
1313
computed: {
1414
...mapState(["meta"]),
1515
sitesFeature() {
16-
var grouped = _.groupBy(this.meta.filter(sample=>sample.Lat&&sample.Long), sample => {
17-
return sample.Lat + sample.Long;
18-
});
16+
var grouped = _.groupBy(
17+
this.meta.filter(sample => sample.Lat && sample.Long),
18+
sample => {
19+
return sample.Lat + sample.Long;
20+
}
21+
);
1922
return {
2023
type: "FeatureCollection",
2124
features: Object.values(grouped).map(group => {

client/src/store/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ Vue.use(Vuex);
77

88
const store = new Vuex.Store({
99
state: {
10+
selectedSampleType: null,
1011
meta: [],
1112
summary: [],
1213
table7: [],
1314
table8: [],
1415
table9: []
1516
},
1617
getters: {},
17-
mutations: {},
18+
mutations: {
19+
setSelectedSampleType(state, type) {
20+
state.selectedSampleType = type;
21+
}
22+
},
1823
actions: {
1924
async load({ state }) {
2025
var { data: records } = await girder.rest.get("record");

client/src/views/Home.vue

Lines changed: 87 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script>
22
import _ from "lodash";
33
import d3 from "d3";
4-
import { mapState, mapActions } from "vuex";
4+
import { mapState, mapMutations, mapActions } from "vuex";
55
66
import NavigationBar from "@/components/NavigationBar";
77
import SampleList from "@/components/SampleList";
@@ -29,20 +29,35 @@ export default {
2929
};
3030
},
3131
computed: {
32-
...mapState(["meta", "summary", "table7", "table8", "table9"]),
32+
...mapState([
33+
"meta",
34+
"summary",
35+
"table7",
36+
"table8",
37+
"table9",
38+
"selectedSampleType"
39+
]),
3340
metaNames() {
3441
return this.meta.map(meta => meta.name);
3542
},
3643
sampleTypes() {
3744
var types = this.meta.map(meta => meta.material).filter(value => value);
38-
return _.uniq(types);
45+
return Object.entries(_.mapValues(_.groupBy(types), "length"));
46+
},
47+
featureTypes() {
48+
var types = this.meta.map(meta => meta.feature).filter(value => value);
49+
return Object.entries(
50+
_.mapValues(_.groupBy(types, type => type), "length")
51+
);
3952
},
4053
ecosystems() {
41-
var ecosystems = this.meta.map(meta => meta.ecosystem).filter(value => value);
42-
return _.uniq(ecosystems);
54+
var ecosystems = this.meta
55+
.map(meta => meta.ecosystem || meta.biome)
56+
.filter(value => value);
57+
return Object.entries(_.mapValues(_.groupBy(ecosystems), "length"));
4358
},
4459
numberOfMetagenomes() {
45-
return this.meta.filter(meta => meta.Sequencing === "Metagenome").length;
60+
return this.meta.length;
4661
},
4762
numberOfMetatranscriptomes() {
4863
return this.meta.filter(meta => meta.Sequencing === "Metatranscriptomes")
@@ -92,6 +107,7 @@ export default {
92107
}
93108
},
94109
methods: {
110+
...mapMutations(["setSelectedSampleType"]),
95111
...mapActions(["load"])
96112
}
97113
};
@@ -112,41 +128,79 @@ export default {
112128
<SamplesLocation />
113129
</v-flex>
114130
<v-flex>
115-
<v-card class="fill-height" color="teal darken-1" dark>
131+
<v-card class="fill-height" color="blue-grey darken-1" dark>
132+
<v-card-title>
133+
<h3>Ecosystems</h3>
134+
</v-card-title>
135+
<v-card-text>
136+
<h4>
137+
<template v-for="([type, count], i) of ecosystems">
138+
<span :key="type">{{ type }} ({{ count }})</span>
139+
<template v-if="i !== ecosystems.length - 1"
140+
>,
141+
</template>
142+
</template>
143+
</h4>
144+
</v-card-text>
145+
</v-card>
146+
</v-flex>
147+
<v-flex>
148+
<v-card class="fill-height" color="indigo darken-1" dark>
116149
<v-responsive :aspect-ratio="16 / 10">
117150
<v-card-title>
118-
<h3>Sample types</h3>
151+
<h3>Feature</h3>
119152
</v-card-title>
120153
<v-card-text>
121-
<h4>{{ sampleTypes.join(",") }}</h4>
154+
<h4>
155+
<template v-for="([type, count], i) of featureTypes">
156+
<span :key="type">{{ type }} ({{ count }})</span>
157+
<template v-if="i !== featureTypes.length - 1"
158+
>,
159+
</template>
160+
</template>
161+
</h4>
122162
</v-card-text>
123163
</v-responsive>
124164
</v-card>
125165
</v-flex>
126166
<v-flex>
127-
<v-card class="fill-height" color="blue-grey darken-1" dark>
128-
<v-card-title>
129-
<h3>Ecosystems</h3>
130-
</v-card-title>
131-
<v-card-text>
132-
<h4>{{ ecosystems.join(",") }}</h4>
133-
</v-card-text>
167+
<v-card class="fill-height" color="teal darken-1" dark>
168+
<v-responsive :aspect-ratio="16 / 10">
169+
<v-card-title>
170+
<h3>Sample types</h3>
171+
</v-card-title>
172+
<v-card-text>
173+
<h4>
174+
<template v-for="([type, count], i) of sampleTypes">
175+
<span
176+
:key="type"
177+
class="sample-type"
178+
:class="{ selected: type === selectedSampleType }"
179+
@click="
180+
selectedSampleType === type
181+
? setSelectedSampleType(null)
182+
: setSelectedSampleType(type)
183+
"
184+
>{{ type }} ({{ count }})</span
185+
>
186+
<template v-if="i !== sampleTypes.length - 1"
187+
>,
188+
</template>
189+
</template>
190+
</h4>
191+
</v-card-text>
192+
</v-responsive>
134193
</v-card>
135194
</v-flex>
136195
<!-- 4 -->
137196
<v-flex>
138-
<v-card class="fill-height" color="indigo darken-1" dark>
197+
<v-card class="fill-height" color="orange darken-2" dark>
139198
<v-card-title>
140199
<h3># metagenome</h3>
141200
</v-card-title>
142201
<v-card-text
143202
><h4>{{ numberOfMetagenomes }}</h4>
144203
</v-card-text>
145-
</v-card>
146-
</v-flex>
147-
<!-- 5 -->
148-
<v-flex>
149-
<v-card class="fill-height" color="orange darken-2" dark>
150204
<v-card-title>
151205
<h3># Metatranscriptomes</h3>
152206
</v-card-title>
@@ -292,4 +346,15 @@ export default {
292346
}
293347
}
294348
}
349+
350+
.sample-type {
351+
&.selected {
352+
text-decoration: underline;
353+
}
354+
355+
&:hover {
356+
cursor: pointer;
357+
text-decoration: underline;
358+
}
359+
}
295360
</style>

server/data/ingest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ def parseTable(directory, filename):
6969
def extractMeta(data):
7070
def getMaterial(name):
7171
if re.search('soil', name, re.IGNORECASE):
72-
return 'Soil'
72+
return 'soil'
7373
elif re.search('water', name, re.IGNORECASE):
74-
return "Water"
74+
return "water"
7575
elif re.search('vegetation', name, re.IGNORECASE):
76-
return 'Vegetation'
76+
return 'vegetation'
7777

7878
def getEcosystem(name):
7979
if re.search('arctic', name, re.IGNORECASE):
80-
return 'Arctic'
80+
return 'arctic'
8181
name = data['meta_']['Genome Name / Sample Name'].split(' - ')[1]
8282
latitude = data['meta_']['Lat']
8383
longitude = data['meta_']['Long']

0 commit comments

Comments
 (0)