<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Matteo Caorsi on Medium]]></title>
        <description><![CDATA[Stories by Matteo Caorsi on Medium]]></description>
        <link>https://medium.com/@matteocaorsi?source=rss-2b71fe755ba1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VcuFNrZXg7taiQQ-</url>
            <title>Stories by Matteo Caorsi on Medium</title>
            <link>https://medium.com/@matteocaorsi?source=rss-2b71fe755ba1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:04:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@matteocaorsi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Local structure of natural language]]></title>
            <link>https://medium.com/@matteocaorsi/local-structure-of-natural-language-4fba137ee31a?source=rss-2b71fe755ba1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fba137ee31a</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[topology]]></category>
            <category><![CDATA[local-homology]]></category>
            <category><![CDATA[word-embeddings]]></category>
            <dc:creator><![CDATA[Matteo Caorsi]]></dc:creator>
            <pubDate>Thu, 18 Aug 2022 22:56:06 GMT</pubDate>
            <atom:updated>2022-08-18T22:56:06.894Z</atom:updated>
            <content:encoded><![CDATA[<p>Co-author: <strong>Jacob Bamberger</strong></p><h3>Introduction</h3><p>Our story begins in the IV century a.C., in Athens. At that time, one of the greatest mind of western philosophy, <a href="https://en.wikipedia.org/wiki/Plato">Plato</a>, was sitting alone in his favourite tavern near the <em>acropolis</em>, sipping wine. He was thinking about the problem of <em>existence</em>. He wanted to understand what nature, humanity and the universe <em>are</em> and why they <em>are</em>. “What are celestial bodies made of?” wondered the philosopher. “Clearly, they cannot be made of rocks, as otherwise they would have already fallen! Neither of water, otherwise they would have already dripped on Earth… Air is invisible, so we shall exclude it as well. How about fire? Flames do go up to the sky: this could be a relevant indication! I just need to find a more convincing argument and then I’ll write my scientific article about it”. This article will be known to posterity as <em>Metaphysics</em>. One of his achievements was to associate nature’s basic elements (rocks, water, air, fire) with regular geometrical shapes: he was able to <em>deduce, from simple geometric principles, </em>that the stars and the moon were neither made of rocks, water, air nor fire! Rather, they needed to be constituted by a 5th element, lighter than fire, that he would call <a href="https://en.wikipedia.org/wiki/Aether_(classical_element)"><em>Aether</em></a>.</p><p>How did Plato reached such conclusion? Well, he (or the mathematicians of the Archimedean school maybe) proved that there are only five regular solids: those that are now known as <a href="https://en.wikipedia.org/wiki/Platonic_solid">the platonic solids</a>. The hypothesis was then to associate to each one of them an element of the physical earth: rocks, water, air and fire. And what’s the 5th? And most importantly, where do we find it? To give an answer to this question he concluded that celestial bodies must be made of the 5th element.</p><p>What does the above story have to do with natural language? Well, what we are exploring in this article is the <strong>relationship between geometry and language</strong>, and, in particular, if we assume that natural language does have a geometric structure, are we able to exploit it and deduce a geometric definition of the <em>meaning of a word</em>? Somehow, we are trying to mimic the reasoning of Plato and hope to discover some new interesting viewpoint on natural language.</p><p><strong>NOTE</strong>: In the next section we are going to show concrete results of word disambiguation: the full notebook with working code can be found <a href="https://github.com/giotto-ai/giotto-tda/blob/master/examples/local_hom_NLP_disambiguation.ipynb">here</a>.</p><h3>The main intuition</h3><p>Let’s focus on the particular problem of word <em>disambiguation</em>. This problem consists of understanding, from the context, whether two homographic words have the same meaning or not.</p><p>Let’s consider a couple of examples:</p><blockquote>“One of the properties is a print history. This will detail the most recent printing activity concerning the file ( although it only records the printing requests , it is not absolute proof that a print was actually produced ) . Note that it only allows a maximum of 250 characters and may therefore not provide a complete history; in the event of the history exceeding this volume , it can only guarantee details of the most recent activity .”</blockquote><p>and</p><blockquote>“Lacking absolute pitch , most of us ca n’t make that connection-labelling a note as ” D ” , for example. But do the connections and labels get hammered in during music lessons , or are some babies just born with a flair for identifying pitch ? That ’s a hard question to answer , since musical parents often pass a passion for music-as well as their genes-on to their children .”</blockquote><p>In the examples above, the word “note” has two different meanings: either a <em>verb</em> or a <em>sound with a well defined frequency</em>. Can machine learning and deep learning algorithms understand this difference? Well, the standard tools based on word embeddings would simply not make it: the reason being that word embeddings takes into account only the <em>grapheme (i.e. how the word is written) </em>when creating the mapping too a vector space! Hence, whether “note” is a verb or a musical pitch, the grapheme is always the same and so would the representing vector [2].</p><h4>The issue with word embeddings</h4><p>Word embeddings are NLP technique that transform a <em>token</em> (a word stripped off of some endings) into a numerical array (this transformation is called <em>vectorisation</em>). This step is needed to allow to input natural language into machine learning models (that require either numbers or arrays of numbers as inputs). One of the most famous algorithms for vectorisation is called <strong>word2vec</strong>. The structure of <strong>word2vec</strong> is that of a simple neural network, which takes as input a word and outputs an associated word embedding. Such algorithm is trained on the task of guessing a missing word in a sentence based on the neighbouring words of that sentence. For more details, you can have a look <a href="https://en.wikipedia.org/wiki/Word2vec">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*BzuFi2Mqrm9LVu_YOps9dQ.png" /><figcaption>Picture taken from <a href="https://www.aclweb.org/anthology/W17-2602.pdf">Context encoders as a simple but powerful extension of word2vec</a> by F. Horn</figcaption></figure><p>Despite this method achieving impressive results, it has a major flaw: <strong>the algorithm will always associate to the same token the same numerical array</strong>. Hence, word disambiguation cannot be solved simply by looking at the <em>vectorisation</em> of the word: how about if we look at the neighbouring words?</p><h3>The main tool: local homology</h3><p>Looking at neighbouring vectorised tokens of a given word is the approach we are taking here: how exactly can we describe, in numerical terms, the shape of the neighbourhood of a word? Concepts from <a href="https://en.wikipedia.org/wiki/Algebraic_topology">algebraic topology</a> comes in handy when we want to describe shapes algebraically: in particular, we are going to exploit the concept of <em>local homology</em>.</p><p>Local homology is the study of the shape of the neighbourhood of a point embedded in a topological space. Let’s consider <strong>a point on the intersection of two lines</strong>, and <strong>a point in the middle of a plane.</strong> These two points, from the viewpoint of local homology, are very different. Why? Well, because the neighbourhoods of two such points look very different!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*iifp-cc9vSFfQSU7sgvr4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*wO_N6mKjo3iolZy0c1HpIQ.png" /><figcaption>The color of these pictures represents the intensity of the “local persistent entropy”: we clearly see that this quantity can differentiate a point by the shape of its neighbouring points. Picture owned by the author and created by Jacob Bamberger</figcaption></figure><p>We can easily generalise the computations to any dimension we like: e.g. a point lying on a sphere, a point lying on the tip of a double cone… But, how can we compute local homology?</p><p>The exact algorithmic procedure to compute local homology is a bit too technical to be described in detail here: the gist of it is to <strong>compute the standard persistent homology of the coned-off relative set</strong>. “Coning-off” means exactly what you see in the picture below: after you define the relative set of interest (in the picture below the intersection of two lines and the disk), you glue together the boundary of your relative set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_c7g4UnFLI85SKIZycwHqQ.png" /><figcaption>Picture owned by the author and created for him by Anastasiia Krupelnytska</figcaption></figure><p>Out of the picture above we can make one observation: from a local neighbourhood of a point we create some very standard topological objects: spheres, circles, bouquet of circles, etc… Once these standard shapes are obtained (via the coning-off procedure shown in the picture above), we can compute the usual homology of such topological space. Put differently, the usual homology of the coned-off local neighbourhood of a point is the local homology of that point. In conclusion, we got what we were looking for: a tool to describe algebraically the local neighbourhood of a point in a topological space.</p><p>One step remains: how do we bridge these local homology computations to natural language?</p><h3>Applications to natural language</h3><p>The missing link is how to apply such local homology techniques to natural language for disambiguation.</p><p>The first observation is that <em>sentences</em> are transformed into <em>point clouds</em> by <strong>word2vec</strong>. And the word we want to disambiguate — say it is the word “note” — is a point in this point cloud. Hence the question: can we build a meaningful topological space out of a point cloud (hence discrete!) so that we can straightforwardly apply the local homology tool?</p><h4>Persistence homology</h4><p>The answer to the above question is a big <strong>YES! </strong>We can actually build many topological spaces out of a point cloud and the next animation gives the intuitive idea on how we can do it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*1ETE9f4D6NgIN__h7uDYqw.gif" /><figcaption>Animation owned and created by the author, representing the basic algorithm of TDA: Vietoris-Rips persistence.</figcaption></figure><p>For a more detailed introduction to topological data analysis (TDA) ad its techniques to compute homology, have a look <a href="https://github.com/giotto-ai/giotto-tda/blob/master/examples/classifying_shapes.ipynb">here</a>.</p><p>So, depending on which scale we consider (corresponding to the radius of the bubbles in the animation above), we can build a <strong>simplicial complex</strong> (i.e. a high dimensional graph, containing vertices, edges, faces,…): <em>a simplicial complex is a topological space</em> and hence homology calculations can be performed.</p><h4>Visualising word embeddings</h4><p>Here below we show the word embeddings of the example sentences above: to reduce to two dimensions, we used the <a href="https://umap-learn.readthedocs.io/en/latest/how_umap_works.html">UMAP algorithm</a>. Notice that there is indeed a difference between the local shapes of the word “note” — represented as a yellow point — in the two picture: can we detect this difference with local homology?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*UIJaVIfJtlbvH0mP4xsSdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*Sd3YlN2Ctr5EH-bEuiohOg.png" /><figcaption>The 2D word embeddings of all the words in the two example sentences. The yellow dot is the word “note”. Picture owned by the author and created by Jacob Bamberger</figcaption></figure><h4>Results</h4><p>By applying local homology to the embeddings above, we are able to distinguish the two meanings! Check the pictures below, taken directly from the<a href="https://github.com/giotto-ai/giotto-tda/blob/master/examples/local_hom_NLP_disambiguation.ipynb"> associated notebook</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DzNvJvQirC9Go_c6n68RAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D6IOXmzJyJXO24rDEa2wEQ.png" /><figcaption>Both pictures are owned by the author and created by Jacob Bamberger.</figcaption></figure><p>There are some parameters to tweak in the algorithm and a full benchmark analysis has to yet be performed on many homographic words. But this task demands a future work!</p><h3>Conclusion</h3><p>The use of local homology to disambiguate words seems a very promising direction. There are published preprints and papers on the topic that all follow the same basic intuition: see [1] and [4].</p><p>While a generic algorithm is available in <a href="https://github.com/giotto-ai/giotto-tda">Giotto-tda</a> [3], a systematic study and benchmark is still lacking: hence, we encourage the interested reader to step up and push forward the knowledge boundary of mankind to better understand natural language and its geometric interpretation.</p><p>[1] Jakubowski A. et al., <a href="https://arxiv.org/pdf/2011.09413.pdf">Topology of Word Embeddings: Singularities Reflect Polysemy</a>, arXiv2011.09413</p><p>[2] Mikolov T. at al., <a href="https://arxiv.org/abs/1301.3781">Efficient Estimation of Word Representations in Vector Space</a>, arXiv:1301.3781</p><p>[3] Tauzin G. et al., <a href="https://arxiv.org/abs/2004.02551">giotto-tda: A Topological Data Analysis Toolkit for Machine Learning and Data Exploration</a>, arXiv2004.02551</p><p>[4] Temčinas T., <a href="https://arxiv.org/pdf/1810.10136.pdf">Local Homology of Word Embeddings</a>, arXiv1810:10136</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fba137ee31a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring brain artery trees with Giotto-tda]]></title>
            <link>https://medium.com/data-science/exploring-brain-artery-trees-with-giotto-tda-688a44c00f59?source=rss-2b71fe755ba1------2</link>
            <guid isPermaLink="false">https://medium.com/p/688a44c00f59</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[brain]]></category>
            <category><![CDATA[topological-data-analysis]]></category>
            <category><![CDATA[stroke]]></category>
            <category><![CDATA[vascular]]></category>
            <dc:creator><![CDATA[Matteo Caorsi]]></dc:creator>
            <pubDate>Mon, 21 Dec 2020 14:46:25 GMT</pubDate>
            <atom:updated>2020-12-21T14:46:25.637Z</atom:updated>
            <content:encoded><![CDATA[<p>How topological data analysis can help in discovering new insights about brain artery trees. Blog post co-author: <strong>R. Andreeva.</strong></p><h3>Introduction</h3><p>Changes in the network of blood vessels (also known as vasculature) are often the first signs of development of diseases like cancer or <a href="https://en.wikipedia.org/wiki/Stroke">stroke</a>. If we are able to develop methods aimed at identifying these alterations, we will be better equipped to treat early these conditions and to develop preventative therapies. Studying the vasculature of the brain is of crucial significance in predicting stroke and brain cancer. With ageing, brain vasculature changes and it is important to be able to recognise and quantify such changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xh_Hx-T8LpC08Y2Et1-lRg.png" /><figcaption>(Image of the author) Prevalence of stroke in the western population. Data from the National Health and Nutrition Examination Survey: 2009–2012</figcaption></figure><p>The main methodological focus of this work is on <a href="https://en.wikipedia.org/wiki/Topological_data_analysis">topological data analysis</a> (TDA). This rather novel technique extract numerical features that quantify the <em>shape </em>of point clouds. A point cloud may have different connected components, loops, voids,… all these peculiar structures can be extracted via TDA techniques. Given the geometric nature of our task at hand (see below for more details), it seems like a very natural choice.</p><p>If you are new to TDA, I recommend you read the following <a href="https://towardsdatascience.com/getting-started-with-giotto-learn-a-python-library-for-topological-machine-learning-451d88d2c4bc">blogpost</a> as an introduction on getting started with <a href="https://arxiv.org/abs/2004.02551">Giotto-tda</a> [4].</p><p>For this purpose, we would like to first study how brain vasculature changes with age for people without accompanying brain conditions. Brain vasculature has been found to be correlated with age from 2 different analysis methods — statistical and TDA. Methods from the former have found age to be correlated with total artery length [3], which forms the basis of our benchmark classification model, together with age, gender and handedness of the subjects. On the other hand, TDA has been useful in identifying correlation between age and the positions of arteries in space in a way that statistical analysis is not capable of discovering [2]. We would focus on calculating the persistence diagrams of the brain artery trees and building a machine learning model capable of distinguishing between brain artery trees coming from 2 different age groups.</p><p>An example of a reconstructed image of an artery tree is shown below (image taken from [2]).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*k5XD-BWQL7BaBoCKSZp8Xg.jpeg" /><figcaption>An example of an artery tree. Picture taken from [2].</figcaption></figure><p>The Jupyter notebook with the detailed computations associated to this blogpost associated to this blog post can be found <a href="https://github.com/giotto-ai/gtda-challenge-2020/blob/master/rorondre/Exploring_brain_artery_trees_and_age_with_giotto_tda.ipynb">here</a>.</p><h3>Overview of the task</h3><p>In this study we are comparing the arteries between non-pathological cases of 98 brains belonging to individuals of age between 18 and 79.</p><p>We will explore the point clouds of brain artery trees, extract topological features which would allow us to quantify looping and branching at multiple levels and train a classifier to distinguish between 2 age groups: group 0 with people younger than 45, and group 1 with people older than 45. It has been suggested in [2] and in <a href="https://towardsdatascience.com/persistent-homology-with-examples-1974d4b9c3d0">this blogpost</a> that topological features can help in identifying the age of a person’s brain, with younger people having significantly longer total artery length and more loops in it. <a href="https://github.com/giotto-ai/giotto-tda">Giotto-tda</a> [4] plays an essential role in this analysis for plotting, calculating persistence diagrams and transforming them into useful feature vectors for the subsequent ML analysis.</p><h3>Dataset</h3><p>The dataset can be found <a href="https://gitlab.com/alexpieloch/PersistentHomologyAnalysisofBrainArteryTrees/-/tree/master/data/OriginalBrainTreeData">here</a>. It consists of 98 artery trees which are the result of applying a <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.102.7885">tube-tracking algorithm</a> to the 3-dimensional Magnetic Resonance Angiography (MRA) images of the brain. Each tree consists of approx. 120000 vertices, branches and edges. For the purpose of this analysis, we have only used a point cloud of all the vertices for initial visualisation and we have randomly downsampled to 500 vertices per tree in order to reduce the computational time. The labels in the dataset depend on the age of the subject: label 0 means that the subject is younger than 45 while label 1 means that the subject is older than 45.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBY35M0xKJeDmb7Z-WCjkw.png" /><figcaption>(Image of the author) In this picture two artery trees are displayed. (Left) the artery tree of a 20 years old subject. (Right) much elderly subject.</figcaption></figure><p>Comparing visually the 2 plots, we notice that the left tree of the 20-year-old subject appears to be very dense with numerous loops forming, while the right tree of the elderly subject is more sparse with less obvious loops forming. This leads us to develop the intuition that calculating the persistent homology in dimension 0, which counts the number of connected components, and persistent homology in dimension 1, which counts the number of loops could be useful for distinguishing between the 2 brains.</p><h3>Persistent homology</h3><p>The core of topological data analysis are <a href="https://en.wikipedia.org/wiki/Persistent_homology">persistence diagrams</a>. These complicated two dimensional diagrams describe the topological properties of a point cloud in a scale-invariant way. We proceed by calculating the <a href="https://en.wikipedia.org/wiki/Persistent_homology">persistence diagrams</a> for homology dimension 0 (which accounts for the connected components) and 1 (which is linked to 1-dimensional loops) only, as higher homology groups require a lot of time for computation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4-Swznhzto-lXBvJeXbDoQ.png" /><figcaption>(Image of the author) In this persistent diagram of a 20-years old patient we see how the class of H1 has many significant features (i.e. the green points far from the diagonal).</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ykhTu9Gct2rggRTsvKwkA.png" /><figcaption>(Image of the author) In this persistent diagram of a 79 years old subject we see how the class of H1 has less significant features than the previous diagram (i.e. the green points far from the diagonal).</figcaption></figure><p>For homology in dimension 1, we can see that there are more points further away from the diagonal in the case of the younger brain. This signifies that there are more loops and the structure of the arteries is <em>loopier</em> than that of the older brain.</p><p>Afterwards, we convert each diagram to a 2-dimensional vector with <a href="https://arxiv.org/abs/1902.06467">persistent entropy</a> [1]. This generates 2 topological features per persistent diagram: one persistent entropy per homology dimension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcRWAdNOkveJAbI3if2zZg.png" /><figcaption>(Image of the author) Scatter plot of the persistent entropies of the young and old patients.</figcaption></figure><p>We are thus able to generate simple numerical feature out of the persistence diagram of a brain. In the plot above, there aren’t any distinct clusters: as a result we cannot expect to have great classification performance based on only these two topological features. What we could try is to add more topological features in order to improve the performances.</p><h3>Integration with machine learning</h3><p>Thanks to topology, we have been able to create new features, such as the persistent entropy one discussed above. These features are associated to each data entry: it implies that we can easily enlarge the number of features in the dataset using Giotto-tda [4]!</p><p>We decided to add four different topological features: they are called <a href="https://giotto-ai.github.io/gtda-docs/0.3.1/modules/generated/diagrams/features/gtda.diagrams.Amplitude.html?highlight=amplitude">amplitudes</a>. The amplitude of a persistent diagram is the result of computing the distance — in a given metric — of such digram from the empty diagram. Depending on which metric is used in the diagram space, such amplitude value may differ. We consider four different metrics to compute a vector of amplitudes for each persistence diagram:</p><pre>&quot;bottleneck&quot;, &quot;wasserstein&quot;, &quot;landscape&quot;, &quot;persistence_image&quot;</pre><p>We also add, to complete the <em>feature engineering</em> step, the number of off-diagonal points per homology dimension. Our intuition relies on the geometric nature of the problem: we believe that to improve the results of a classification tasks, we can add topological features to the dataset. Let’s see what we can do!</p><p>We use <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html">RandomForestClassifier</a> for classification after the feature engineering step. The final classification <a href="https://en.wikipedia.org/wiki/Accuracy_and_precision">accuracy</a> is:</p><pre>0.735</pre><h3>Comparison with a reasonable benchmark</h3><p>We compare the classifier with topological features with a simple baseline based on a geometric measure — the total artery length. We add two more features, which are gender and handedness (which is tendency to use either the right or the left hand more naturally than the other) which we have available for the dataset.</p><p>The accuracy of the same RandomForestClassifier is:</p><pre>0.714</pre><p>We note a 2% increase in performance in the topological features compared to the baseline. However, it should be noted that the original dataset contained more than 120K points. The choice to downsample was for computational reasons so that the code can run in less than 15 mins. Attempts with 3000, 2000, 1000 points were made, but the time it took was substantially longer. The results are expected to be better when we have more data points.</p><p>We can also add more topological features, try other classifiers and perform hyper-parameters tuning, and use techniques such as boosting to improve the performance.</p><h3>Conclusion</h3><p>In this blogpost we have obtained interesting results regarding the relationship between brain artery trees and age, and developed a useful classification model which distinguishes between younger and older brains with <strong>73.4% accuracy</strong>. The topological features slightly outperform the geometric measurement of total brain artery length in the age classification task. However, we are only using a small subsample of 500 of the available vertices (out of 120k), which suggests that there might be more accurate classification when one includes more points. It would be interesting to see if adding more points to the point clouds would change the accuracy and of how much. The caveat will be a longer time to produce the full set of persistence diagrams, with approximately 1 minute per diagram for a point cloud of 3000 points, which would result in 90 mins for the entire dataset. Further methods for speeding up this process could be investigated, together with a more accurate sampling procedure, as we used random subsampling. Moreover, in further analysis we should also calculate the homology of dimension 2, as that could provide additional insight.</p><p>We have considered the ageing effect on healthy individuals’ brain arteries. In future work it would be of clinical interest to develop topological techniques for detecting brain abnormalities linked to brain conditions such as stroke and brain cancer. Giotto-tda played the central role in this analysis [4], and it could be used to further add more topological features and for useful interpretations of linking biological biomarkers with the topology of the brain arteries.</p><h3>References</h3><p>[1] N. Atienza et al., <a href="https://arxiv.org/abs/1902.06467">Persistent entropy: a scale-invariant topological statistic for analyzing cell arrangements</a>, ArXiv1902.06467</p><p>[2] P. Bendich et al., <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5026243/">Persistent Homology Analysis of Brain Artery Trees</a>, PMID: 27642379</p><p>[3] J. Gutierrez et al., <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4836884/">Brain arterial aging and its relationship to Alzheimer dementia</a>, <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4836884/#">Neurology</a>. 2016 Apr 19; 86(16): 1507–1515.</p><p>[4] G. Tauzin et al., <a href="https://arxiv.org/abs/2004.02551">giotto-tda: A Topological Data Analysis Toolkit for Machine Learning and Data Exploration</a>, ArXiv2004.02551</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=688a44c00f59" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/exploring-brain-artery-trees-with-giotto-tda-688a44c00f59">Exploring brain artery trees with Giotto-tda</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An explainable topological search engine with Giotto-tda]]></title>
            <link>https://medium.com/data-science/an-explainable-topological-search-engine-with-giotto-tda-f1f3b2769a57?source=rss-2b71fe755ba1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1f3b2769a57</guid>
            <category><![CDATA[search-engines]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[topological-data-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Matteo Caorsi]]></dc:creator>
            <pubDate>Sun, 13 Dec 2020 18:50:23 GMT</pubDate>
            <atom:updated>2020-12-14T13:40:01.372Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to use topology to enhance natural language search engines.</h4><p>The co-author of the blogpost: <a href="https://medium.com/@c.filip.cornell/about"><strong>F. Cornell</strong></a><strong>.</strong></p><h3>Introduction</h3><p>In this blog post, based on the work by <a href="https://medium.com/@c.filip.cornell/about">F. Cornell</a>, we explain how one can use Giotto-tda [2] to cluster words and create a semantical search engine, retrieving documents similar to one&#39;s query, thereby showing how we can use topological techniques in the context of Natural Language Processing (NLP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6SobDMg7H9ijCpfdhGA_Jg.jpeg" /><figcaption>(Photo by <a href="https://unsplash.com/@raphaelphotoch?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Raphael Schaller</a> on <a href="https://unsplash.com/s/photos/words?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a>) Natural language processing (NLP) is the field studying the interaction between human languages with computers.</figcaption></figure><p>We will be using the classical <a href="https://www.nltk.org/book/ch02.html"><em>Reuters</em></a> dataset, consisting of around 10K news documents collected from Reuters (inherently available in the <a href="https://www.nltk.org/"><em>nltk</em></a><em> </em>package). We will also use pre-trained word vectors, available through the <a href="https://radimrehurek.com/gensim/"><em>gensim</em></a> API. These are the <a href="https://github.com/mmihaltz/word2vec-GoogleNews-vectors"><em>word2vec-google-news-300</em></a>.</p><p>If you are new to TDA, I recommend you read the following <a href="https://towardsdatascience.com/getting-started-with-giotto-learn-a-python-library-for-topological-machine-learning-451d88d2c4bc">blog post</a> as an introduction on getting started with giotto-tda [2]. This <a href="https://towardsdatascience.com/visualising-high-dimensional-data-with-giotto-mapper-897fcdb575d7">one</a> is also useful to better understand the Mapper algorithm used below.</p><p>The reader can find all the implementation details and the fully working code in <a href="https://github.com/giotto-ai/gtda-challenge-2020/blob/master/filco306/A_topological_search_engine.ipynb">this Jupyter notebook</a>.</p><h3>How do we use giotto-tda for a search engine?!</h3><p>A problem with many search engine techniques today is that they rely on the words to exist in the corpus of a document that are already indexed.</p><p>When we search for certain terms in a collection of documents, many methods often look for the specific words, and this can be troublesome. A great example of a TF-IDF based approach for a search engine is the <a href="https://www.kaggle.com/amitkumarjaiswal/nlp-search-engine">Kaggle notebook</a> by Amit Kumar Jaiswal. Nevertheless, it also points out the weakness of this approach. Words in the query that do not exist in the documents vocabulary are removed from the query, and we might lose important information regarding what the user is searching for.</p><h4>Building the Mapper graph</h4><p>A tool that allows for constructing a search engine mitigating this problem is the <a href="https://giotto-ai.github.io/gtda-docs/latest/notebooks/mapper_quickstart.html">Mapper algorithm</a> in Giotto-tda. By taking the word vectors of all the words existing in a collection of documents, we can create a graph from these word vectors by using the Mapper method. Each node will then work as a cluster of words that are similar and often replaceable by each other. Due to the inherent nature of word vectors, words are perceived as similar when they are used in the same context (see [2]) and can be measured with the use of the cosine similarity. We, therefore, use the cosine distance as our distance metric when constructing our graph.</p><p>In essence, the mapper allows us to cluster the words into an arbitrary number of clusters, <strong>not a pre-determined number of clusters</strong>, with words that are similar in terms of semantical meaning. If a word does not exist, we can rely on its neighbours, defined through the vertices it belongs to, to fetch a document that might be about similar topics.</p><p>This mapper graph can then be used to query the data and retrieve documents. Each document has words belonging to different nodes, as different words end up in different nodes based on which words they are similar to. A document will therefore implicitly belongs to many different nodes as it is a collection of words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hj1QtN7LPXSAYmnyQvRBsA.png" /><figcaption>(Image of the author) The Mapper graph of Reuters’ dataset. The filter function used is the output of the 2D t-SNE dimensionality reduction technique.</figcaption></figure><h4>How querying the Mapper graph works</h4><p>We can explain a query in a few steps. Let’s say a word is searched for, e.g. Soybean. We then look up which nodes this word belongs to: the same node would also contains other words and therefore be associated with many different documents. We look at all documents that have words in those nodes, and the documents are ranked <em>based on their percentage of words contained in the same node as the query</em>. In the simple example of Soybean, we simply rank all documents based on the percentage of the words they have in the same nodes as Soybean. The output of the query is the list of documents, ranked as just described. If a word does not exist in the corpus, we can simply leverage the word vectors and derive the most similar word that exists in the corpus.</p><p>The construction of the Mapper graph therefore works as an efficient way of clustering words and implicitly creating what one might call a topological signature for each document.</p><p>For a brief <strong>mathematical formulation of the problem</strong>, please refer to the <a href="https://github.com/giotto-ai/gtda-challenge-2020/blob/master/filco306/A_topological_search_engine.ipynb">Jupyter notebook</a> associated with this blog post.</p><h3>Results</h3><p>Let’s take a look at an example where we can clearly see the semantics of the mapper graph at work.</p><p>Below is a search for “oil”, for which one of the top results is “SINGAPORE PETROLEUM CO RAISES OIL PRODUCT POSTING”. The first result perfectly matches the most used connotation of the word “oil” as fossil fuel, and the second result is about minerals and fossil fuels as well! The topological search engine captures semantics and meanings in the documents that <a href="https://pypi.org/project/rank-bm25/"><em>BM25</em></a> does not (see the benchmark below for comparison)!</p><pre>RESULT 0 for the query &#39;oil&#39;: <br> <br>SINGAPORE PETROLEUM CO RAISES OIL PRODUCT POSTINGS<br>  Singapore Petroleum Co Pte Ltd said it<br>  will raise posted prices for its products from June 19, by one<br>  cent/gallon for lpg, naphtha and gasoline, two cents for gas<br>  oil and by 60 cents/barrel for marine diesel oil.<br>      New prices are - lpg 36.0 cents/gallon, chemical naphtha<br>  47, unleaded reformate 65.8, 0.4 gm lead 97 octane 61.3, 95<br>  octane 59.3, 92 octane 55.5, 85 octane 49.5, 0.125 gm lead 97<br>  octane 64.3, 92 octane 58.5, 85 octan...</pre><pre>RESULT 1 for the query &#39;oil&#39;: <br> <br>HOUSTON METALS&#39; MINE YIELDS POSITIVE RESULTS<br>  &amp;lt;Houston Metals Corp&gt; said the<br>  the first phase of the underground rehabilitation, extensive<br>  drilling and bulk sampling program at its Silver Queen Mine has<br>  yielded positive results.<br>      Houston said representative assays from the 2,750 ft and<br>  2,600 ft levels at the south end of the mine established ore<br>  deposits in the following ranges: copper, 3.7 pct to 5.08 pct,<br>  lead .99 pct to 1.5 pct, zinc six pct to 9.6 pct, silver 15.63<br>  pct ...</pre><pre>RESULT 2 for the query &#39;oil&#39;: <br> <br>API SAYS DISTILLATE, GAS STOCKS OFF IN WEEK<br>  Distillate fuel stocks held in<br>  primary storage fell by 4.4 mln barrels in the week ended Feb<br>  27 to 127.10 mln barrels from 131.50 mln the previous week, the<br>  American Petroleum Institute (API) said.<br>      In its weekly statistical bulletin, the oil industry trade<br>  group said gasoline stocks fell 30,000 barrels to 252.92 mln<br>  barrels from a revised 252.95 mln, while crude oil stocks rose<br>  700,000 barrels to 329.38 mln from a revised 328.68 mln...</pre><h4>Comparison with another algorithm</h4><p>Here below, we compare the Mapper-based search engine with a classical method, the <em>BM25</em> search method. Following <a href="https://pypi.org/project/rank-bm25/">its guide on how to use it</a>, we rank and retrieve results for the same keyword searches as in the topological method. We search for “oil” to compare with the topological approach.</p><pre>RESULT 0 for the query &#39;oil&#39;: <br> <br>DIAMOND SHAMROCK (DIA) CUTS CRUDE PRICES<br>  Diamond Shamrock Corp said that<br>  effective today it had cut its contract prices for crude oil by<br>  1.50 dlrs a barrel.<br>      The reduction brings its posted price for West Texas<br>  Intermediate to 16.00 dlrs a barrel, the copany said.<br>      &quot;The price reduction today was made in the light of falling<br>  oil product prices and a weak crude oil market,&quot; a company<br>  spokeswoman said.<br>      Diamond is the latest in a line of U.S. oil companies that<br>  have cut...</pre><pre>RESULT 1 for the query &#39;oil&#39;: <br> <br>GLOBAL PETROLEUM &amp;lt;GNR&gt; UPS HEAVY FUEL PRICES<br>  Global Petroleum Corp said it had raised<br>  the contract prices for heavy fuel oil from 25 cts to one dlr<br>  per barrel, effective today.<br>      The company said 0.3 pct fuel oil is up one dlr a barrel to<br>  22.25 dlrs a barrel. They said 0.5 pct fuel oil is up by 50 cts<br>  to 21.95 dlrs a barrel.<br>      Global raised one pct fuel oil by 35 cts to 20.25 dlrs a<br>  barrel. The company raised 2.2 pct fuel by 25 cts to 19.50 dlrs<br>  a barrel. Global raised 2...</pre><pre>RESULT 2 for the query &#39;oil&#39;: <br> <br>ENERGY ANALYST PROPOSES U.S. OIL TARIFF<br>  Energy analyst Edward Krapels said<br>  the United States should consider an oil tariff to keep U.S.<br>  dependence on imports below 50 pct.<br>      &quot;On the supply side, the argument in favor of a contingent,<br>  variable import tariff is most persuasive,&quot; Krapels, president<br>  of Energy Security Analysis, Inc said in a statement at a House<br>  Energy and Power subcommittee hearing.<br>      &quot;An optimal tariff would be one implemented only if the<br>  international price...</pre><p>The semantic richness oil as “fossil fuel” is completely lost in the top ranked documents: all top results explicitly contain the word “oil”.</p><h3>Wrap-up and further work</h3><p>In this work, we demonstrated a proof-of-concept, showing how it is possible to use Giotto-tda and its packages within NLP to create a semantic search engine. As seen with some examples (see oil) the <strong>Topological Search Engine captures semantics that BM25, a classical search engine, does not manage to capture.</strong></p><h4>Future directions</h4><p>There are however a few points that need to be highlighted.</p><ul><li><strong>Edges are not explicitly leveraged</strong>, which probably can be of value. In an extension of this, the edges should be used in some way to increase the search radius and possibly retrieve more relevant search results. As an example, if a document has many of its words in a neighbour to the node of the query, it can still be a highly relevant document for the query in question.</li><li>Constructing a Mapper graph is in many ways an arbitrary process, in which it is not always clear <strong>which filtering function</strong> and which overlap fractions and number of partitions we should use. In further work, one should investigate whether it is better with richer representations containing more nodes (higher number of partitions) and rich connectivity, as opposed to larger nodes (with fewer partitions) and lower connectivity. A higher connectivity means more words will belong to more nodes, yielding a more descriptive representation of each document. It is clear that this method can be further refined by further examination.</li></ul><p>More work is absolutely needed to improve these results; most of all, this method can clearly be fine-tuned to work better. Either way, this blog post serves as a demonstration that Giotto-tda and topology have their places within the realm of Natural Language Processing. It also shows, for a few sets of queries, that the topological search engine is not necessarily inferior to classical methods such as BM25; with more adjustments, we truly hope it could probably perform even better.</p><h3>References</h3><p>[1] T. Mikolov, <a href="https://papers.nips.cc/paper/2013/file/9aa42b31882ec039965f3c4923ce901b-Paper.pdf">Distributed Representations of Words and Phrases and their Compositionality</a>, Advances in neural information processing systems 26 (2013): 3111–3119.</p><p>[2] G. Tauzin et al., <a href="https://arxiv.org/abs/2004.02551">giotto-tda: A Topological Data Analysis Toolkit for Machine Learning and Data Exploration</a>, ArXiv2004.02551</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1f3b2769a57" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/an-explainable-topological-search-engine-with-giotto-tda-f1f3b2769a57">An explainable topological search engine with Giotto-tda</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Proteins of Learning]]></title>
            <link>https://medium.com/data-science/the-proteins-of-learning-4d89a5b265ae?source=rss-2b71fe755ba1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d89a5b265ae</guid>
            <category><![CDATA[machine-learning-pipeline]]></category>
            <category><![CDATA[topological-data-analysis]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[gene-expression]]></category>
            <dc:creator><![CDATA[Matteo Caorsi]]></dc:creator>
            <pubDate>Mon, 07 Dec 2020 18:20:34 GMT</pubDate>
            <atom:updated>2020-12-07T18:20:34.918Z</atom:updated>
            <content:encoded><![CDATA[<h4>Or how to characterise the gene expression of proteins involved in cognitive processes using topological data analysis</h4><h3>Introduction</h3><p>The use of <a href="https://en.wikipedia.org/wiki/Topological_data_analysis">topological data analysis</a> (TDA)in genomics has been rising over the last years: this <a href="https://www.cambridge.org/core/books/topological-data-analysis-for-genomics-and-evolution/FCC8429FAD2B5D1525AEA47A8366D6EB">book</a> [2] extensively summarises the current research status. The current article is about a success story on how to use TDA to better understand protein expression and the effect of drugs on proteins expressions.</p><p>This analysis has been applied to real data, real diseases and real drugs. The <a href="https://en.wikipedia.org/wiki/Memantine"><em>Memantine</em></a> compound is being currently used in curing Alzheimer disease: are we really understanding how this drug affects our body?</p><p>The rest of this article presents a detailed analysis on how to use TDA (in particular, <a href="https://en.wikipedia.org/wiki/Persistent_homology">persistent homology</a> and the <a href="https://giotto-ai.github.io/gtda-docs/0.3.1/notebooks/mapper_quickstart.html">Mapper algorithm</a>) to cluster the data without loosing its high dimensional shape and how it is possible to extract novel insights from such data. In particular, as it will be shown below, an unsupervised analysis of the dataset turns out to be essential in order to extract meaningful genomic characteristics: the individuality of test subject is far too great to be able to extract stable and generalisable results with a naive analysis.</p><p>If you are new to TDA, I recommend you read the following <a href="https://towardsdatascience.com/getting-started-with-giotto-learn-a-python-library-for-topological-machine-learning-451d88d2c4bc">blogpost</a> as an introduction on getting started with <a href="https://arxiv.org/abs/2004.02551">giotto-tda</a> [3]. This <a href="https://towardsdatascience.com/visualising-high-dimensional-data-with-giotto-mapper-897fcdb575d7">one</a> is also useful to better understand the Mapper algorithm used below.</p><p>This article has been written in collaboration with <em>Mara Sabina Bernardi</em>. The Jupyter notebook used to perform this analysis can be found <a href="https://github.com/giotto-ai/gtda-challenge-2020/blob/master/marabernardi/learning-proteins.ipynb">here</a>.</p><h3>The problem</h3><p>Many diseases can affect our ability to learn: two amongst the most infamous examples are the Alzheimer disease and the Down syndrome. The Down Syndrome is characterised by a trisomy of chromosome 21, thus augmenting the expression of those proteins coded by such chromosome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*XMopRalEfqQkU3W7oc6ECg.gif" /><figcaption>Trisomy in the human genome. Picture taken from <a href="https://upload.wikimedia.org/wikipedia/commons/6/6f/Trisomie_21_Genom-Schema.gif">https://upload.wikimedia.org/wikipedia/commons/6/6f/Trisomie_21_Genom-Schema.gif</a> and under Creative Commons licenses (allowed to be reused)</figcaption></figure><p>Unfortunately, the excess of the synthesis of certain proteins can have dreadful consequences on the functioning of the human body. In particular, the excess of certain neurotransmitters, i.e. proteins whose purpose is to pass messages amongst neurons, may saturate the communication channels between the neurons themselves, preventing a proper propagation of the information through the brain. The phenotypical consequence is the loss of mental abilities (such as the possibility to learn and memorise) as well as physical clumsiness and poor coordination.</p><p>Recent advances in the pharmaceutical technologies have allowed for the the development of new drugs to treat such diseases, for example by inhibiting the expression of certain proteins: <em>Memantine</em> is one example. Unfortunately, it is not yet known what is the effect on gene expression on humans of this drug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*f82XJd-du0FW28rLKrzqZA.png" /><figcaption>Picture of the Memantine molecule. Taken from <a href="https://it.wikipedia.org/wiki/Memantina#/media/File:Memantine-3d-sticks.png">https://it.wikipedia.org/wiki/Memantina#/media/File:Memantine-3d-sticks.png</a> and under Creative Commons licenses (allowed to be reused)</figcaption></figure><p>The purpose of this post is to present an analysis pipeline that uses TDA to better understand protein expressions in learning tasks. Furthermore, we will also show which are the proteins whose expression is modified by the use of <em>Memantine</em>.</p><p>The analysis has been implemented using the library <a href="https://github.com/giotto-ai/giotto-tda">giotto-tda</a> [3].</p><p>The dataset is described in <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0129126">C. Higuera et al. </a>[1].</p><h4>Acknowledgement</h4><p>The following analysis has been inspired by the work of <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0129126">C. Higuera et al.</a> [1].</p><h3>Description of the dataset</h3><p>The <a href="http://archive.ics.uci.edu/ml/datasets/Mice+Protein+Expression">dataset</a> used consists of the expression levels of 77 proteins/protein modifications that produced detectable signals in the nuclear fraction of cortex. There were 38 control mice and 34 trisomic mice, for a total of 72 mice. Measurements were made using <a href="http://reverse phase protein arrays">reverse phase protein arrays</a> (RPPA), a high throughput technique in which protein samples from individual mice are robotically spotted onto nitrocellulose-coated microscope slides.</p><p>There are eight different classes of mice: four classes are composed of normal mice (i.e. control mice, as they are used for reference), while the other four classes are composed of Down-syndromic mice. Part of the control mice and down mice are stimulated to learn a specific task; some are injected with <em>Memantine</em>, some others not.</p><p>The combination of control mice VS Down mice, stimulated to learn VS not stimulated to learn and injected with Memantine VS not injected with Memantine constitute the eight classes.</p><h4>Purpose of the analysis</h4><p>The aim of the analysis is to identify those proteins that are discriminant for the different classes.</p><h3>Pipeline</h3><p>The analysis is structured in the following five steps:</p><h4><strong>1. Data Preprocessing</strong></h4><p>This step is standard and it consists of cleaning up the data and normalise it. We can also try to visualise the dataset by using a 3D PCA: unfortunately, the complexity of the dataset does not allow for a clear understanding of the feature space: indeed, the shape of the dataset (which will be analysed in the next section) is distorted by this representation. Therefore, a more refined analysis is required: in particular, we chose to use the persistent homology to better understand the shape of the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1C0isq6aBcK9Rla3jmMqnQ.png" /><figcaption>(Image by author) The 3D PCA plot of the point cloud. Different colours represent different classes. This representation completely distort the original high dimensional shape of the point cloud.</figcaption></figure><h4><strong>2. Understanding the Shape of the Dataset</strong></h4><p>In this exploratory phase, we use <a href="https://en.wikipedia.org/wiki/Persistent_homology">persistent homology</a> to get an idea of what is the global shape of the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LU8j7dMFDJrpERHDz_PJZA.png" /><figcaption>(Image by author) Persistent diagram, whose interpretation suggests that there are no large loops in the dataset and eight connected components (two of which are clearly separated).</figcaption></figure><p>This diagram shows us, abstractly, what the shape of our point cloud looks like. In particular, when looking at the H0 component (i.e. the red points), we see (top left) that there are eight points that are separated from the others. These are reasonably separated connected components. On the other hand, there are no relevant 1-loops in the dataset, as demonstrated by the H1 component (i.e. the noisy green points, close to the diagonal of the diagram).</p><h4><strong>3. Naive Wilcoxon Approach</strong></h4><p>We use the <a href="https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test">Wilcoxon rank-sum test</a> to differentiate the protein distribution amongst the different classes. This technique will highlight how protein expression varies amongst the different classes. Unfortunately, due to the individuality of each mouse, the results are too noisy to reach meaningful conclusions. Hence, we need to refine the analysis with an unsupervised technique.</p><h4><strong>4. Application of the Mapper Algorithm</strong></h4><p>We apply the <a href="https://giotto-ai.github.io/gtda-docs/0.3.1/notebooks/mapper_quickstart.html">Mapper algorithm</a> and try to relate its shape with a finer decomposition of the classes. The purpose would be to refine the classes and study the difference in protein expressions not amongst single individuals but rather amongst regions of the mapper graph. This will remove noise due to individuality and allow us to better identify the critical proteins. We apply again the Wilcoxon rank-sum test to quantify the significance of protein expressions amongst different regions of the Mapper graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LZytAoLg8RBxEAs7mQvlOA.png" /><figcaption>(Image by author) The Mapper graph, produced by the Mapper algorithm. This neat graphical representation of the dataset highlights clusters composed mainly of mice belonging to the same class. Colours provide information about the classes of the mice in the nodes (see below).</figcaption></figure><p>How do we interpret the Mapper graph? Each node is a small cluster of points. An edge exists if the two connected nodes have some data points in common. The colour of a node is an <em>average</em> of the labels. The association of colours with the classes, relevant for the final analysis, is the following:</p><pre>Down mice stimulated to learn, injected with Memantine &lt;--&gt; Yellow<br>Down mice stimulated to learn, not injected &lt;--&gt; Azure<br>Control mice, stimulated to learn, not injected &lt;--&gt; Green<br>Control mice, not stimulated to learn, not injected &lt;--&gt; Deep purple</pre><p>Let us point out that there is no use of this “average” except to help the visual intuition to understand how classes changes over the graph! Nodes with just one colour are called <strong>pure </strong>and they will be considered for the final Wilcoxon test. As a <strong>filter function</strong>, we used the 3D output of the <a href="https://umap-learn.readthedocs.io/en/latest/api.html">UMAP</a> algorithm, another very powerful topological tool used for dimensionality reduction.</p><p>The clusters found by the mapper algorithm, clearly show that there are many similar groups of mice within a class. Thus, we proceed with a comparison of proteins expressions between such clusters, hoping to remove individuality from the game.</p><h4>5. Benchmark with standard clustering</h4><h4>5.1. DBScan</h4><p>We benchmark the results of step 4 of the analysis with a more standard clustering algorithm: <a href="https://scikit-learn.org/stable/modules/generated/sklearn.cluster.DBSCAN.html">DBScan()</a>.</p><p>In the next figure, we see how the dataset is far too noisy to be properly described by the clustering algorithm, as the number of clusters is heavily influenced by the nearest neighbours parameter 𝜖 without a clear indication of what would be the correct number of clusters to consider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bNxyZ-iaO7k_BV4r7hD9nA.png" /><figcaption>(Image by author) The number of clusters found by the DBScan algorithm as a function of the 𝜖 parameter. The instability of the result makes it hard to use this technique in the analysis.</figcaption></figure><h4>5.2. KMeans</h4><p>We benchmark with the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html">KMeans()</a> clustering algorithm to see if we can find a reasonable number of clusters via the elbow method.</p><p>As we can see in the next figure, there is no clear elbow: hence, also in this case, we cannot decide on the optimal number of clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKq4dZx1iL_3vd4tVjA7-Q.png" /><figcaption>(Image by author) Inertia index with different number of clusters. There curve is decreasing without elbows, thus making it impossible to use this method for clustering.</figcaption></figure><h3>Results</h3><p>To find the relevant proteins, the Wilcoxon rank-sum test is applied to the <strong>Mapper</strong> <strong>pure clusters only</strong>. Wilcoxon test compares two distributions: hence, the questions that can be answered by this statistical test are about comparisons between the distributions of the protein expressions of two chosen classes. For a chosen class, each Mapper pure cluster is thus compared with all the pure clusters of the other chosen class. The comparison is done via the Wilcoxon rank-sum test and it analyses protein expressions one at a time. The proteins that pass the test are tho ones selected. To make results robust, only the proteins that are selected by the Wilcoxon test <strong>in all the comparisons among pure clusters</strong> are taken into account.</p><p>While most of the proteins expressions that we identified are present in both the current analysis and in the work of <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0129126">C. Higuera et al. </a>[1], <strong>there are some relevant differences concerning the Memantine effect on protein expressions</strong>. Thus, the topological methods are indicating that some features related to the shape of the overall point cloud are to be taken into account when performing protein expression analysis. Experts could give further interpretations to these results.</p><ul><li>The proteins that are relevant for learning in control mice are:</li></ul><pre>{&#39;pERK_N&#39;, &#39;pGSK3B_N&#39;, &#39;SOD1_N&#39;}</pre><ul><li>The proteins that are relevant for learning in down mice that are not affected by Memantine are:</li></ul><pre>{&#39;pS6_N&#39;, &#39;pMTOR_N&#39;, &#39;pAKT_N&#39;, &#39;pERK_N&#39;, &#39;pCAMKII_N&#39;, &#39;ADARB1_N&#39;, &#39;ARC_N&#39;, &#39;CaNA_N&#39;, &#39;NR2B_N&#39;, &#39;SOD1_N&#39;, &#39;pNR2A_N&#39;, &#39;DYRK1A_N&#39;, &#39;GSK3B_N&#39;, &#39;P38_N&#39;, &#39;IL1B_N&#39;, &#39;Ubiquitin_N&#39;}</pre><ul><li>The proteins whose expression is affected by the Memantine drug in down mice are:</li></ul><pre>{&#39;pPKCAB_N&#39;, &#39;pPKCG_N&#39;, &#39;NUMB_N&#39;, &#39;pERK_N&#39;, &#39;pJNK_N&#39;, &#39;pCAMKII_N&#39;, &#39;S6_N&#39;, &#39;NR2B_N&#39;, &#39;CAMKII_N&#39;}</pre><p>For a detailed list of the proteins names, please refer to the <a href="https://github.com/giotto-ai/gtda-challenge-2020/blob/master/marabernardi/learning-proteins.ipynb">analysis notebook</a> or the original paper [1].</p><h3>Conclusions</h3><p>The individuality of each mouse affects protein expression. Such individuality is far too great to have meaningful and interpretable results using standard statistical approach as the Wilcoxon rank-sum test. Grouping together individuals with similar genetic characteristics in an unsupervised way is necessary to obtain meaningful results. Thus, we need to cluster mice together to better understand how protein expression affect a sub-cluster.</p><p>The use of the <strong>Mapper algorithm</strong> allowed for a more accurate identification of the most relevant proteins taking part in the learning tasks. Furthermore, thanks to this powerful technique — which does not require at all a pre-defined number of clusters — it was possible to characterise which proteins expressions are affected by the <em>Memantine </em>compound. The Wilcoxon rank-sum test applied to portions of the Mapper graph enhanced the results significantly and allowed for a precise identification of the relevant proteins.</p><p>The use of more standard clustering approaches such as DBScan— which does not require to set a-priori the number of expected clusters — or KMeans has clear limitations in terms of better understanding which groups to consider together. This can be clearly seen by the instability of the number of clusters even with small variations of the nearest neighbours parameter for DBScan or the absence of elbows for KMeans.</p><h3>References</h3><p>[1] C. Higuera et al., <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0129126">Self-Organizing Feature Maps Identify Proteins Critical to Learning in a Mouse Model of Down Syndrome</a>, PloS one 10.6 (2015): e0129126.</p><p>[2] R. Rabadan et al., <a href="https://www.cambridge.org/core/books/topological-data-analysis-for-genomics-and-evolution/FCC8429FAD2B5D1525AEA47A8366D6EB">Topological Data Analysis for Genomics and Evolution</a>, Cambridge University Press, ISBN: 9781316671665</p><p>[3] G. Tauzin et al., <a href="https://arxiv.org/abs/2004.02551">giotto-tda: A Topological Data Analysis Toolkit for Machine Learning and Data Exploration</a>, ArXiv2004.02551</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d89a5b265ae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/the-proteins-of-learning-4d89a5b265ae">The Proteins of Learning</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>