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

try to have a better ratio h, w for cell

parent a0cce9bd
Branches dev
No related tags found
No related merge requests found
Pipeline #127326 waiting for manual action with stages
in 10 minutes and 8 seconds
...@@ -18,7 +18,12 @@ const itemValue = ref("id"); ...@@ -18,7 +18,12 @@ const itemValue = ref("id");
const { width } = useDisplay(); const { width } = useDisplay();
const dbName = ref("refseq") const dbName = ref("refseq")
const taxonomyFacet = ref<Record<string, any> | undefined>(undefined) const taxonomyFacet = ref<Record<string, any> | undefined>(undefined)
const cellPlotMargin = ref({
marginLeft: 150,
marginBottom: 200,
marginTop: 0,
marginRight: 50
})
onBeforeMount(async () => { onBeforeMount(async () => {
...@@ -150,7 +155,7 @@ const availableTaxo: Ref<string[]> = ref([ ...@@ -150,7 +155,7 @@ const availableTaxo: Ref<string[]> = ref([
"Superkingdom" "Superkingdom"
]); ]);
const scaleTypes = ref<string[]>(['linear', 'sqrt', 'log', 'symlog']) const scaleTypes = ref<string[]>(['linear', 'sqrt', 'symlog'])
const selectedTaxoRank = ref<"species" | "genus" | "family" | "order" | "class" | "phylum" | "Superkingdom">("Superkingdom"); const selectedTaxoRank = ref<"species" | "genus" | "family" | "order" | "class" | "phylum" | "Superkingdom">("Superkingdom");
const headers = ref([ const headers = ref([
...@@ -190,7 +195,18 @@ const computedWidth = computed(() => { ...@@ -190,7 +195,18 @@ const computedWidth = computed(() => {
return Math.max(currentWidth, 550); return Math.max(currentWidth, 550);
}); });
const cellPlotComputedDimension = computed(() => {
const { marginLeft, marginBottom, marginRight, marginTop } = toValue(cellPlotMargin)
const toValWidth = toValue(width)
const widthFixCell = countSystem.value * 50 + marginLeft + marginRight
const heigthFix = countClade.value * 50 + marginTop + marginBottom
if (widthFixCell > toValWidth) {
return { width: toValWidth - marginLeft - marginRight, height: undefined }
} else {
return { width: widthFixCell, height: heigthFix }
}
})
const allHits: Ref<Record<string, any> | undefined> = ref(undefined) const allHits: Ref<Record<string, any> | undefined> = ref(undefined)
...@@ -360,17 +376,33 @@ const sortedCellDomain = computed(() => { ...@@ -360,17 +376,33 @@ const sortedCellDomain = computed(() => {
} }
}) })
const binPlotOptions = computed(() => { const binPlotOptions = computed(() => {
const { marginLeft, marginBottom } = toValue(cellPlotMargin)
const { height } = toValue(cellPlotComputedDimension)
return { return {
marginLeft: 150, marginLeft,
marginBottom: 200, marginBottom,
padding: 0, padding: 0,
grid: true, grid: true,
aspectRatio: true, aspectRatio: height ? undefined : 1,
x: { tickRotate: 90, label: "Systems", domain: toValue(sortedCellDomain) }, x: { tickRotate: 90, label: "Systems", domain: toValue(sortedCellDomain) },
color: { scheme: "plasma", legend: true, label: `Proportion per ${selectedTaxoRank.value}`, domain: [0, 100] }, color: { scheme: "plasma", legend: true, label: `Proportion per ${selectedTaxoRank.value}`, domain: [0, 100] },
} }
}) })
const countSystem = computed(() => {
const toValueAllHits = toValue(allHits)
const data = toValueAllHits?.hits ?? []
const setSystem = new Set(data.map(d => d.type))
return setSystem.size
})
const countClade = computed(() => {
const toValueAllHits = toValue(allHits)
const data = toValueAllHits?.hits ?? []
const setSystem = new Set(data.map(d => d[selectedTaxoRank.value]))
return setSystem.size
})
const binPlotGroup = computed(() => { const binPlotGroup = computed(() => {
return Plot.group( return Plot.group(
...@@ -419,9 +451,13 @@ const binPlotDataOptions = computed(() => { ...@@ -419,9 +451,13 @@ const binPlotDataOptions = computed(() => {
const toValBinPlotGroup = toValue(binPlotGroup) const toValBinPlotGroup = toValue(binPlotGroup)
const data = toValueAllHits?.hits ?? [] const data = toValueAllHits?.hits ?? []
const plotCellMark = Plot.cell(data, toValBinPlotGroup) const plotCellMark = Plot.cell(data, toValBinPlotGroup)
const { width, height } = toValue(cellPlotComputedDimension)
const dim = height ? { width, height } : { width }
return toValueAllHits?.hits?.length > 0 ? { return toValueAllHits?.hits?.length > 0 ? {
...binPlotOptions.value, ...binPlotOptions.value,
width: width.value, ...dim,
title: `Proportion of genomes with defense system X per ${selectedTaxoRank.value} taxonomic rank`, title: `Proportion of genomes with defense system X per ${selectedTaxoRank.value} taxonomic rank`,
color: { color: {
...binPlotOptions.value.color, ...binPlotOptions.value.color,
......
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