Skip to content
Merged
4 changes: 3 additions & 1 deletion microsetta_interface/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,9 @@ def get_sample_results(*, account_id=None, source_id=None, sample_id=None):
if has_error:
return sample_output

if sample_output['sample_site'] == 'Stool':
if sample_output['sample_site'] in [
Comment thread
AmandaBirmingham marked this conversation as resolved.
'Stool', 'Right Hand', 'Left Hand', 'Torso', 'Forehead', 'Cheek'
]:
page = 'new_results_page.jinja2'
else:
page = 'sample_results.jinja2'
Expand Down
119 changes: 94 additions & 25 deletions microsetta_interface/templates/new_results_page.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,14 @@
};

function getMicrobiomeMapsRasterizedPlots(state) {
if(state.dataset_type.value === 'WGS') {
var pcoa_plots = ['tmi_WGS_gut_multipop', 'tmi_WGS_gut_lifestage'];
if(state.dataset_site.value === 'gut') {
if(state.dataset_type.value === 'WGS') {
var pcoa_plots = ['tmi_WGS_gut_multipop', 'tmi_WGS_gut_lifestage'];
} else {
var pcoa_plots = ['tmi_16S_gut_all_samples', 'tmi_16S_gut_multipop', 'tmi_16S_gut_lifestage', 'tmi_16S_gut_builtenv'];
}
} else {
var pcoa_plots = ['tmi_16S_gut_all_samples', 'tmi_16S_gut_multipop', 'tmi_16S_gut_lifestage', 'tmi_16S_gut_builtenv'];
var pcoa_plots = [];
Comment thread
AmandaBirmingham marked this conversation as resolved.
}

for (var key of pcoa_plots) {
Expand Down Expand Up @@ -475,6 +479,8 @@
break;
case "tmi-WGS-gut":
case "tmi-16S-gut":
case "tmi-WGS-skin":
case "tmi-16S-skin":
label = '{{ _('The Microsetta Initiative') }}';
span_id = "#dataset_links_tmi";
break;
Expand Down Expand Up @@ -529,11 +535,21 @@
{
var have_wgs = false;
var have_16S = false;
var body_site = '';

for (var i = 0; i < data.length; i++) {
if(data[i] === 'tmi-WGS-gut') {
have_wgs = true;
body_site = 'gut';
} else if(data[i] === 'tmi-WGS-skin') {
have_wgs = true;
body_site = 'skin';
} else if(data[i] === 'tmi-16S-gut') {
have_16S = true;
body_site = 'gut';
} else if(data[i] === 'tmi-16S-skin') {
have_16S = true;
body_site = 'skin';
Comment thread
AmandaBirmingham marked this conversation as resolved.
}
}

Expand All @@ -555,8 +571,6 @@
}

state.dataset_type.value = 'WGS';
state.dataset_site.value = 'gut';
state.dataset_input.value = 'tmi-WGS-gut';
} else {
for (var i = 0; i < data.length; i++) {
$.ajax({
Expand All @@ -569,9 +583,10 @@
}

state.dataset_type.value = '16S';
state.dataset_site.value = 'gut';
state.dataset_input.value = 'tmi-16S-gut';
}

state.dataset_site.value = body_site;
state.dataset_input.value = 'tmi-' + state.dataset_type.value + '-' + body_site;
}
});
}
Expand Down Expand Up @@ -984,6 +999,11 @@
"id": "one_liter_of_water_a_day_frequency",
"operator": "equal",
"value": "Regularly (3-5 times/week)"
},
{
Comment thread
AmandaBirmingham marked this conversation as resolved.
"id": "one_liter_of_water_a_day_frequency",
"operator": "equal",
"value": "Daily"
}
]
}
Expand All @@ -998,6 +1018,11 @@
"id": "exercise_frequency",
"operator": "equal",
"value": "Regularly (3-5 times/week)"
},
{
"id": "exercise_frequency",
"operator": "equal",
"value": "Daily"
}
]
}
Expand Down Expand Up @@ -1027,19 +1052,35 @@
]
}
}
const us_avg =
Comment thread
AmandaBirmingham marked this conversation as resolved.
{
"metadata_query":
{
"condition": "OR",
"rules": [
{
"id": "country_residence",
"operator": "equal",
"value": "United States"
}
]
}
}

const POST_DATA = {
"plants": more_than_30_plants,
"water": water_frequency,
"exercise": exercise_regularly,
"sleep": sleep_more_than_6_hrs
"sleep": sleep_more_than_6_hrs,
"us_avg": us_avg
}

const SELECTORS = {
"plants": "#diversity_30_plants_per_week",
"water": "#diversity_water_regularly",
"exercise": "#diversity_exercise_regularly",
"sleep": "#diversity_sleep_alot"
"sleep": "#diversity_sleep_alot",
"us_avg": "#average-american-observed-average-" + state.dataset_site.value
}

// We override the default alpha_metric from state for this page.
Expand Down Expand Up @@ -1207,13 +1248,10 @@
}

function updateObservedAverages(state) {
var us_text = document.getElementById('average-american-observed-average');
var hadza_text = document.getElementById('average-hadza-observed-average');
if (state.dataset_type.value === 'WGS') {
us_text.innerText = '5.31';
hadza_text.innerText = '6.30';
} else if (state.dataset_type.value === '16S') {
us_text.innerText = '4.47';
hadza_text.innerText = '5.20';
}
}
Expand Down Expand Up @@ -1245,7 +1283,17 @@
}
);

// First, hide all of the site-specific content
Comment thread
AmandaBirmingham marked this conversation as resolved.
const all_site_specific_elements = document.getElementsByClassName("site_specific_content");
for (let i = 0; i < all_site_specific_elements.length; i++) {
all_site_specific_elements[i].style.display = "none";
}

// Then, display the site-specific content for our current dataset
const site_specific_elements = document.getElementsByClassName("site_specific_content_" + state.dataset_site.value);
for (let i = 0; i < site_specific_elements.length; i++) {
site_specific_elements[i].style.display = "";
}
}

//Called immediately after a tab is shown
Expand Down Expand Up @@ -1423,7 +1471,7 @@
<li class="nav-item">
<a class="nav-link" id="taxonomy-tab" data-bs-toggle="tab" href="#taxonomy" role="tab" aria-controls="taxonomy" aria-selected="false">{{ _('Composition') }}</a>
</li>
<li class="nav-item">
<li class="nav-item site_specific_content site_specific_content_gut">
<a class="nav-link" id="microbial-map-tab" data-bs-toggle="tab" href="#microbial-map" role="tab" aria-controls="microbial-map" aria-selected="false">{{ _('Microbiome Map') }}</a>
</li>
<li class="nav-item">
Expand Down Expand Up @@ -1471,7 +1519,7 @@
</div>
</br>

<div class="how_you_compare_section">
<div class="how_you_compare_section site_specific_content site_specific_content_gut" id="how_you_compare_microbiome_map">
<h4>{{ _('Microbiome Map') }}</h4>
<p>
{{ _('Where are you on the <a class="fake-tab" href="#microbial-map" data-link="#microbial-map-tab">Microbiome Map</a>?') }}
Expand All @@ -1489,31 +1537,46 @@
<p>
<strong>{{ _('How do we calculate your diversity value?') }}</strong>
</p>
<p>
<p class="site_specific_content site_specific_content_gut">
{{ _('Diversity can be measured in a lot of different ways. We measure it by first taking the DNA sequences from your sample and figuring out which Bacteria and Archaea they may have come from. This produces a good estimate of how many of each kind of microbe you have. The measure we use, called Shannon\'s index, takes into account how many different kinds of microbes make up your gut community (also known as richness) and how relatively abundant each of those microbes are (also known as evenness).') }}
</p>
<p>
{{ _('This number isn\'t exact for many reasons. However, because it\'s calculated in the same way for every sample in our dataset, it provides insight into how your microbial diversity compares to others\'. For example, the <span id="average-us-tooltip" class="orange-text" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="top" title="Based on fecal samples from Microsetta participants in the United States">average</span> diversity value for people living in the US in our dataset is <strong id="average-american-observed-average">FILLIN</strong>, which is lower than we find in people living a more hunter-gatherer lifestyle like the <span id="taxa-tooltip" class="orange-text" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="top" title="The Hadza are an indigenous hunter-gather group in Tanzania. The summary of the Hadza microbiome is based on Smits et al. Science 2017">Hadza</span> people of Tanzania, who have an average value of <strong id="average-hadza-observed-average">FILLIN</strong>. ') }}
<p class="site_specific_content site_specific_content_skin">
{{ _('Diversity can be measured in a lot of different ways. We measure it by first taking the DNA sequences from your sample and figuring out which Bacteria and Archaea they may have come from. This produces a good estimate of how many of each kind of microbe you have. The measure we use, called Shannon\'s index, takes into account how many different kinds of microbes make up your skin community (also known as richness) and how relatively abundant each of those microbes are (also known as evenness).') }}
</p>
<p class="site_specific_content site_specific_content_gut">
{{ _('This number isn\'t exact for many reasons. However, because it\'s calculated in the same way for every sample in our dataset, it provides insight into how your microbial diversity compares to others\'. For example, the <span id="average-us-tooltip" class="orange-text" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="top" title="Based on fecal samples from Microsetta participants in the United States">average</span> diversity value for people living in the US in our dataset is <strong id="average-american-observed-average-gut">FILLIN</strong>, which is lower than we find in people living a more hunter-gatherer lifestyle like the <span id="taxa-tooltip" class="orange-text" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="top" title="The Hadza are an indigenous hunter-gather group in Tanzania. The summary of the Hadza microbiome is based on Smits et al. Science 2017">Hadza</span> people of Tanzania, who have an average value of <strong id="average-hadza-observed-average">FILLIN</strong>. ') }}
</p>
<p class="site_specific_content site_specific_content_skin">
{{ _('This number isn\'t exact for many reasons. However, because it\'s calculated in the same way for every sample in our dataset, it provides insight into how your microbial diversity compares to others\'. For example, the <span id="average-us-tooltip" class="orange-text" data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="top" title="Based on cheek samples from participants in the United States">average</span> diversity value for people living in the US in our dataset is <strong id="average-american-observed-average-skin">FILLIN</strong>.') }}
</p>
<p>
<strong>{{ _('What does this number mean for my health?') }}</strong>
</p>
<p>
<p class="site_specific_content site_specific_content_gut">
{{ _('This number reflects the variety of Bacteria and Archaea observed in your fecal sample at the time of testing. Currently, there\'s no standard for how gut microbiome diversity relates to health. While some studies suggest a potential link between higher diversity and specific health benefits, that is not true universally and more research is needed to understand the relationship. For example, it may be that the specific microbes present are more important than having many different types of microbes.') }}
</p>
<p>
<p class="site_specific_content site_specific_content_skin">
{{ _('This number reflects the variety of Bacteria and Archaea observed in your skin sample at the time of testing. Currently, there\'s no standard for how skin microbiome diversity relates to health. While some studies suggest a potential link between lower diversity and risk for certain skin conditions, that is not true universally and more research is needed to understand the relationship. For example, it may be that the specific microbes present are more important than having many different types of microbes.') }}
</p>
<p class="site_specific_content site_specific_content_gut">
{{ _('It\'s important to remember that everyone\'s gut microbiome is unique and changes over time. If your score differs from the average, it doesn\'t necessarily indicate a health concern.') }}
</p>
<p class="site_specific_content site_specific_content_skin">
{{ _('It\'s important to remember that everyone\'s skin microbiome is unique and changes over time. If your score differs from the average, it doesn\'t necessarily indicate a health concern.') }}
</p>
<div class="card your_sample_diversity_inset">
<div class="card-header">{{ _('Your sample\'s diversity value:') }}</div>
<div class="card-body">
<span id="diversity_in_sample" class="info-loader">...</span></h5>
</div>
</div>
<br />
<p>
<p class="site_specific_content site_specific_content_gut">
{{ _('When we calculated the diversity of the sample groups in our database, we found that it\'s closely associated with how you live your life. So here, we summarized the average diversity from our database for a few questions asked on the survey.') }}
</p>
<p class="site_specific_content site_specific_content_skin">
{{ _('Here, we summarized the average diversity from our database for a few questions asked on the survey.') }}
</p>

<div class="row mb-2 mt-2">
<div class="col diversity-compare">
Expand Down Expand Up @@ -1563,12 +1626,18 @@
</div>
</div>
</div>
<p>
<p class="site_specific_content site_specific_content_gut">
<strong>{{ _('How can I change my gut microbiome based on my results?') }}</strong>
</p>
<p>
<p class="site_specific_content site_specific_content_skin">
<strong>{{ _('How can I change my skin microbiome based on my results?') }}</strong>
Comment thread
AmandaBirmingham marked this conversation as resolved.
</p>
<p class="site_specific_content site_specific_content_gut">
{{ _('Although we still don\'t have a predictable way to change the gut microbiome to increase or decrease the abundance of specific microorganisms, we know that various factors influence gut microbial community composition. Diet is a significant factor affecting the gut microbiome, so by changing your diet, you may be able to alter your gut microbiome. Certain probiotics could also influence your gut microbiome while actively taking them; however, research into this area is still in its early days. Factors such as stress can also change the gut microbiome. Finally, keep in mind that factors we can\'t change, such as age or genetics, can affect the gut microbiome.') }}
</p>
<p class="site_specific_content site_specific_content_skin">
{{ _('Although we still don\'t have a predictable way to change the skin microbiome to increase or decrease the abundance of specific microorganisms, we know that various factors influence skin microbial community composition. Environmental exposure is a significant factor affecting the skin microbiome, so by changing your surroundings, you may be able to alter your skin microbiome. For example, studies have shown that skin microbiomes can differ based on whether you live in an urban or rural area, and that your skin microbiome tends to be much more similar to the people you live with than those you don\'t live with. However, keep in mind that factors we can\'t change, such as age or genetics, also affect the skin microbiome.') }}
</p>
</div>
</div>
<div class="tab-pane fade" id="similarity" role="tabpanel" aria-labelledby="similarity-tab">
Expand Down Expand Up @@ -1618,7 +1687,7 @@
<img class="diversity-icon" src='/static/img/probiotics.png'>
</div>
<div class="col-sm-8 diversity-text">
{{ _('<span id="beta_diversity_probiotics_value" class="info-loader font-weight-bold">...</span> of people with a microbiome like yours <span id="beta_diversity_probiotics_response" class="info-loader text-success">...</span> take probiotics') }}
{{ _('<span id="beta_diversity_probiotics_value" class="info-loader font-weight-bold">...</span> of people with a microbiome like yours take probiotics <span id="beta_diversity_probiotics_response" class="info-loader text-success">...</span>') }}
</div>
</div>
<div class="col diversity-compare">
Expand Down Expand Up @@ -1666,7 +1735,7 @@
<img class="diversity-icon" src='/static/img/age.png'>
</div>
<div class="col-sm-8 diversity-text">
{{ _('<span id="beta_diversity_age_value" class="info-loader font-weight-bold">...</span> of people with a microbiome like yours were the same age as you') }}
{{ _('<span id="beta_diversity_age_value" class="info-loader font-weight-bold">...</span> of people with a microbiome like yours were a similar age to you') }}
</div>
</div>
<div class="col diversity-compare">
Expand All @@ -1686,7 +1755,7 @@
<h3>{{ _('Your Inner Zoo (aka What\'s in your sample?)') }}</h3>
<br>
<p>
{{ _('This is a table of all of the different microbes we found in your sample along with their proportions.') }}
{{ _('This is a table of all of the different bacteria and archaea we found in your sample along with their proportions.') }}
</p>

<p>
Expand Down