Skip to content
Snippets Groups Projects
Commit 1e76012b authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Normalize by given clade

parent c81fe6bd
No related branches found
No related tags found
1 merge request!222Refseq no sys
Pipeline #123365 failed
...@@ -25,26 +25,29 @@ onBeforeMount(async () => { ...@@ -25,26 +25,29 @@ onBeforeMount(async () => {
index: toValue(dbName), query: "", params: { index: toValue(dbName), query: "", params: {
facets: ["*"], facets: ["*"],
filter: [], filter: [],
page: 1, limit: 500000,
hitsPerPage: 25, sort: ["type:asc"]
} }
}) })
autocompleteMeiliFacetsProps.value.facetDistribution = toValue(data)?.facetDistribution autocompleteMeiliFacetsProps.value.facetDistribution = toValue(data)?.facetDistribution
allHitsDb.value = toValue(data)?.hits
}) })
const allHitsDb = ref<Record<string, any>[] | undefined>(undefined)
onMounted(async () => { onMounted(async () => {
const { data } = await useAsyncMeiliSearch({ const { data } = await useAsyncMeiliSearch({
index: toValue(dbName), query: "", params: { index: toValue(dbName), query: "", params: {
facets: ["*"], facets: ["*"],
filter: [], filter: [],
page: 1, // page: 1,
hitsPerPage: 25, // hitsPerPage: 25,
limit: 500000,
sort: ["type:asc"]
} }
}) })
autocompleteMeiliFacetsProps.value.facetDistribution = toValue(data)?.facetDistribution autocompleteMeiliFacetsProps.value.facetDistribution = toValue(data)?.facetDistribution
allHitsDb.value = toValue(data)?.hits
}) })
...@@ -238,11 +241,12 @@ const computedDistriSystemOptions = computed(() => { ...@@ -238,11 +241,12 @@ const computedDistriSystemOptions = computed(() => {
// Taxo distri // Taxo distri
const computedTaxonomyDistribution = computed(() => { const computedTaxonomyDistribution = computed(() => {
const toValNormalizePerAssembly = toValue(normalizePerAssembly) const toValSelectedTaxoRank = toValue(selectedTaxoRank)
if (toValNormalizePerAssembly?.length > 0) { const toValFacetsPerRank = toValue(msResult)?.facetDistribution?.[toValSelectedTaxoRank]
return Object.entries(toValue(msResult).facetDistribution[selectedTaxoRank.value]).map(([key, value]) => { if (toValFacetsPerRank) {
return Object.entries(toValFacetsPerRank).map(([key, value]) => {
return { return {
[selectedTaxoRank.value]: key, [toValSelectedTaxoRank]: key,
count: value count: value
} }
}).sort() }).sort()
...@@ -298,11 +302,27 @@ const binPlotOptions = ref({ ...@@ -298,11 +302,27 @@ const binPlotOptions = ref({
grid: true, grid: true,
x: { tickRotate: 90, tip: true, label: "Systems" }, x: { tickRotate: 90, tip: true, label: "Systems" },
// y: { tickFormat: 's' }, // y: { tickFormat: 's' },
color: { scheme: "plasma", legend: true }, color: { scheme: "plasma", legend: true, domain: [0, 100] },
})
const binPlotGroup = computed(() => {
return Plot.group(
{
fill: "count"
},
{
x: "type",
y: selectedTaxoRank.value,
tip: true,
inset: 0.5,
sort: { y: "fill" }
})
}) })
const binPlotDataOptions = computed(() => { const binPlotDataOptions = computed(() => {
const toValueAllHits = toValue(allHits) const toValueAllHits = toValue(allHits)
const data = toValueAllHits?.hits ?? []
return toValueAllHits?.hits?.length > 0 ? { return toValueAllHits?.hits?.length > 0 ? {
...binPlotOptions.value, ...binPlotOptions.value,
width: width.value, width: width.value,
...@@ -312,9 +332,47 @@ const binPlotDataOptions = computed(() => { ...@@ -312,9 +332,47 @@ const binPlotDataOptions = computed(() => {
type: scaleType.value, type: scaleType.value,
tickFormat: '~s', tickFormat: '~s',
ticks: scaleType.value === 'symlog' ? 3 : 5, ticks: scaleType.value === 'symlog' ? 3 : 5,
}, },
marks: [ marks: [
Plot.cell(toValueAllHits?.hits ?? [], Plot.group({ fill: "count" }, { x: "type", y: selectedTaxoRank.value, tip: true, inset: 0.5, sort: { y: "fill" } })), Plot.cell(data, Plot.group(
{
fill: {
label: `Normalize by ${selectedTaxoRank.value} clade`,
reduceIndex: function (I, X) {
const toValAssemblyPerRank = toValue(assemblyPerRank)
if (toValAssemblyPerRank?.size > 0) {
const clade = X[I[0]][selectedTaxoRank.value]
const system = X[I[0]].type
console.log(I)
console.log(X)
// Get the list of item for this group
const itemsPerGroup = d3.rollup(I.map(index => {
return X[index]
}), D => D.length, d => d.type, d => d.Assembly)
console.log(itemsPerGroup)
// console.log(clade)
// console.log(toValAssemblyPerRank.get(clade))
const countForClade = toValAssemblyPerRank.get(clade).size
// console.log(countForClade)
// console.log(I);
// console.log(X);
const frequency = (itemsPerGroup.get(system).size / countForClade) * 100
console.log(frequency)
return frequency
}
return I.length
}
}
},
{
x: "type",
y: selectedTaxoRank.value,
tip: true,
inset: 0.5,
sort: { y: "fill" }
}))
] ]
} : null } : null
...@@ -357,11 +415,21 @@ const systemPerAssemblyPerRank = computed(() => { ...@@ -357,11 +415,21 @@ const systemPerAssemblyPerRank = computed(() => {
} }
}) })
const assemblyPerRank = computed(() => { const systemPerRankPerAssembly = computed(() => {
const toValueAllHits = toValue(allHits) const toValueAllHits = toValue(allHits)
console.log("all hits dans system per...")
console.log(toValueAllHits)
if (toValueAllHits && toValueAllHits?.hits?.length > 0) { if (toValueAllHits && toValueAllHits?.hits?.length > 0) {
return d3.rollup(toValueAllHits.hits, D => D.length, d => d[toValue(selectedTaxoRank)], d => d.Assembly) return d3.rollup(toValueAllHits.hits, D => D.length, d => d[toValue(selectedTaxoRank)], d => d.type, d => d.Assembly)
}
})
const assemblyPerRank = computed(() => {
const toValueAllHits = toValue(allHitsDb)
if (toValueAllHits && toValueAllHits?.length > 0) {
return d3.rollup(toValueAllHits, D => D.length, d => d[toValue(selectedTaxoRank)], d => d.Assembly)
} }
}) })
...@@ -585,8 +653,8 @@ async function downloadPng(component: ComponentPublicInstance | null, filename: ...@@ -585,8 +653,8 @@ async function downloadPng(component: ComponentPublicInstance | null, filename:
</v-chip> </v-chip>
</template> </template>
<template #[`item.replicon`]="{ item }"> <template #[`item.replicon`]="{ item }">
<v-chip color="info" link size="small" <v-chip color="info" link size="small" :href="`https://www.ncbi.nlm.nih.gov/nuccore/${item.replicon}`"
:href="`https://www.ncbi.nlm.nih.gov/nuccore/${item.replicon}`" target="_blank"> {{ target="_blank"> {{
item.replicon }} item.replicon }}
</v-chip> </v-chip>
</template> </template>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment