Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
profileview
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Edoardo SARTI
profileview
Commits
2e428b54
Commit
2e428b54
authored
May 18, 2022
by
Edoardo Sarti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree similarity final notebook
parent
df3fb1f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
532 additions
and
0 deletions
+532
-0
tree_similarity.ipynb
tree_similarity/tree_similarity.ipynb
+532
-0
No files found.
tree_similarity/tree_similarity.ipynb
0 → 100644
View file @
2e428b54
{
"cells": [
{
"cell_type": "code",
"execution_count": 82,
"id": "edb197fc",
"metadata": {},
"outputs": [],
"source": [
"from ete3 import Tree\n",
"import math\n",
"import random\n",
"import numpy as np\n",
"import scipy.stats"
]
},
{
"cell_type": "markdown",
"id": "38abced4",
"metadata": {},
"source": [
"# Toy models"
]
},
{
"cell_type": "code",
"execution_count": 83,
"id": "55e52783",
"metadata": {},
"outputs": [],
"source": [
"def permutations(h,d=1):\n",
" \"\"\"Lists all binary permutations of histogram h (must have a length of a power of 2)\"\"\"\n",
" hlen = len(h)\n",
" if hlen == d:\n",
" return [h]\n",
" if hlen > 16:\n",
" return None\n",
" \n",
" iblist = []\n",
" for i in range(2**d):\n",
" ib = [int(x) for x in ('{:b}'.format(i)).zfill(d)]\n",
" iblist.append(ib)\n",
" res = []\n",
" binlength = int(hlen/d)\n",
" sme = []\n",
" for i in range(0,hlen,binlength):\n",
" sme.append((i,i+int(binlength/2),i+binlength))\n",
" hlist = []\n",
" for ib in iblist:\n",
" hnew = h[:]\n",
" for i, tripl in enumerate(sme):\n",
" if ib[i]:\n",
" s, m, e = tripl\n",
" hnew = hnew[:s] + hnew[m:e] + hnew[s:m] + hnew[e:]\n",
" hlist.append(hnew)\n",
" newlist = []\n",
" for hh in hlist:\n",
" newlist += permutations(hh,d*2)\n",
" return newlist"
]
},
{
"cell_type": "code",
"execution_count": 84,
"id": "7a9df981",
"metadata": {},
"outputs": [],
"source": [
"def probhist(hh1, hh2, symm=True, v=False):\n",
" if v:\n",
" print(hh1)\n",
" print(hh2)\n",
" # Pseudocounts\n",
" eps = 0.00001\n",
" h1 = [x+(max(hh1)-min(hh1)+eps)/100 for x in hh1]\n",
" h2 = [x+(max(hh2)-min(hh2)+eps)/100 for x in hh2]\n",
" \n",
" # Normalize histos\n",
" s1, s2 = sum(h1), sum(h2)\n",
" nh1, nh2 = [x/s1 for x in h1], [x/s2 for x in h2]\n",
" if v:\n",
" print(\"Normalized histos\")\n",
" print(nh1)\n",
" print(nh2)\n",
" \n",
" # Couple histos and sort second\n",
" twonhs = list(zip(nh1,nh2))\n",
" twonhs = sorted(twonhs, key= lambda x:x[1])\n",
" if v:\n",
" print(\"TWONHS\")\n",
" print(twonhs)\n",
" \n",
" # Sort both histos and then couple\n",
" twosortednhs = list(zip(sorted(nh1), sorted(nh2)))\n",
" if v:\n",
" print(\"TWOSORTEDNHS\")\n",
" print(twosortednhs)\n",
" \n",
" # Probability model\n",
" dp = []\n",
" for i in range(len(nh1)):\n",
" for j in range(i, len(nh2)):\n",
" dp.append(abs(nh1[i] - nh2[j]))\n",
" mu = sum(dp)/len(dp)\n",
" mu2 = sum([x**2 for x in dp])/len(dp)\n",
" sigma = (mu2 - mu**2)**0.5\n",
" model = scipy.stats.norm(mu, sigma)\n",
" binsize = 0.01\n",
" \n",
" # Cross-mutual information\n",
" # SUM f(h1,h2) log2 (f(h1,h2) / f(h1',h2')) with h2 = h2'\n",
" res = 0\n",
" for i in range(len(h1)):\n",
" dif = abs(twonhs[i][0]-twonhs[i][1])\n",
" srtdif = abs(twosortednhs[i][0]-twosortednhs[i][1])\n",
" p = model.cdf(dif+binsize) - model.cdf(dif-binsize)\n",
" sp = model.cdf(srtdif+binsize) - model.cdf(srtdif-binsize)\n",
" res += p * math.log(p/sp, 2)\n",
" if v:\n",
" print(h1[i], p * math.log(p/sp, 2), p, sp, math.log(p/sp, 2), dif, srtdif)\n",
"\n",
" return res"
]
},
{
"cell_type": "code",
"execution_count": 85,
"id": "caf1a874",
"metadata": {},
"outputs": [],
"source": [
"def agg_vector(h):\n",
" l = len(h)\n",
" hlist = [h]\n",
" newh = [] # list of all the upper histos\n",
" while len(hlist[-1]) > 2:\n",
" for i, v in enumerate(hlist[-1]):\n",
" if i%2==0:\n",
" newh.append(v)\n",
" else:\n",
" newh[-1] += v\n",
" hlist.append(newh)\n",
" newh = []\n",
" res = []\n",
" for hh in hlist:\n",
" res += hh\n",
" return res\n",
"\n",
"def aggregated_permutations(h1):\n",
" ps = permutations(h1)\n",
" for ips in range(len(ps)):\n",
" ps[ips] = agg_vector(ps[ips])\n",
" return ps\n",
"\n",
"def aggmaxprobhist(h1, h2, allout=False):\n",
" aggps = aggregated_permutations(h1)\n",
" am = np.argmin([probhist(h,agg_vector(h2)) for h in aggps])\n",
" if allout:\n",
" return am, aggps[am], probhist(aggps[am],agg_vector(h2))\n",
" return probhist(aggps[am],agg_vector(h2), v=False)"
]
},
{
"cell_type": "code",
"execution_count": 86,
"id": "dff1ab66",
"metadata": {},
"outputs": [],
"source": [
"def tests(f):\n",
" answ = []\n",
" \n",
" # Reference\n",
" h1 = [10,9,8,7,12,10,7,5]\n",
" answ.append((h1, True, 'Reference'))\n",
" \n",
" # h1-h2 are similar (organisation problem) \n",
" h2 = [10,9,8,7,13,10,7,5]\n",
" answ.append((h2, True, 'Almost identical'))\n",
"\n",
" # h1-h3 are not similar (null hypothesis problem)\n",
" h3 = [10,5,8,7,12,10,7,9]\n",
" answ.append((h3, False, 'Identical sorting but not permutable'))\n",
" \n",
" # h1-h4 are similar (noise problem)\n",
" h4 = [11,8,7,8,11,9,8,6]\n",
" answ.append((h4, True, 'noise'))\n",
" \n",
" # h1-h5 are similar (topology problem)\n",
" h5 = [12,10,7,5,10,9,8,7]\n",
" answ.append((h5, True, 'Permutable'))\n",
"\n",
" # h1-h6 are similar (non-proportional incrementation problem)\n",
" h6 = [x+100000 for x in h1]\n",
" answ.append((h6, False, 'non-proportional increment'))\n",
"\n",
" # h1-h7 are not similar (null case)\n",
" h7 = [max(0,random.uniform(-1,1))*512 for x in h1]\n",
" answ.append((h7, False, 'Random big numbers or zero'))\n",
"\n",
" # h1-h8 are not similar (unbalance case)\n",
" h8 = [0, 0, 0, 0, 10000, 10000, 10000, 10000]\n",
" answ.append((h8, False, 'max unbalance'))\n",
" \n",
" # h1-h9 are similar (proportional incrementation problem)\n",
" h9 = [x*100 for x in h1]\n",
" answ.append((h9, True, 'proportional increment'))\n",
" \n",
" print(\"#### \" + f.__name__ + \" ####\")\n",
" for h, a, c in answ:\n",
" print(\"{0:50s} {1} {2:20.6f} {3}\".format(c, h, f(h1, h), a))\n",
" print(\"\\n\") \n",
" \n",
" print(\"--- Incremental noise on signal ---\")\n",
" for magn in range(11):\n",
" sph = 0\n",
" sqsph = 0\n",
" for rep in range(10):\n",
" coef = 3*magn/10\n",
" hr = [max(0,random.gauss(x, coef)) for x in h1]\n",
" ph = f(h1,hr)\n",
" sph += ph\n",
" sqsph += ph**2\n",
" #if ph > 50:\n",
" # print(h1, hr, magn, ph)\n",
" print(\"{0:<30d} {1:15.6f} +/- {2:10.6f}\".format(magn, sph/100, (sqsph/100 - (sph/100)**2)**0.5))\n",
" print(\"\\n\")\n",
" \n",
" print(\"--- Incremental random noise ---\")\n",
" for magn in range(11):\n",
" sph = 0\n",
" sqsph = 0\n",
" for rep in range(10):\n",
" hr = [random.random()*10*magn for x in h1]\n",
" ph = f(h1,hr)\n",
" sph += ph\n",
" sqsph += ph**2\n",
" #if ph > 50:\n",
" # print(h1, hr, magn, ph)\n",
" print(\"{0:<30d} {1:15.6f} +/- {2:10.6f}\".format(magn, sph/100, (sqsph/100 - (sph/100)**2)**0.5))\n",
" print(\"\\n\")\n",
" \n",
" print(\"--- Incremental unbalanced distribution ---\")\n",
" hrr = [0]*int(len(h1)/2) + [1]*int(len(h1)/2)\n",
" for magn in range(1,11):\n",
" hr = [1+x*10*magn for x in hrr]\n",
" print(\"{0:<30d} {1:15.6f}\".format(magn, f(h1,hr)))\n",
" print(\"---\")\n",
" print(\"\\n\\n\")"
]
},
{
"cell_type": "markdown",
"id": "a7f41851",
"metadata": {},
"source": [
"## Tests"
]
},
{
"cell_type": "code",
"execution_count": 94,
"id": "9eade642",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"#### aggmaxprobhist ####\n",
"Reference [10, 9, 8, 7, 12, 10, 7, 5] 0.000000 True\n",
"Almost identical [10, 9, 8, 7, 13, 10, 7, 5] 0.000000 True\n",
"Identical sorting but not permutable [10, 5, 8, 7, 12, 10, 7, 9] 0.189489 False\n",
"noise [11, 8, 7, 8, 11, 9, 8, 6] 0.000000 True\n",
"Permutable [12, 10, 7, 5, 10, 9, 8, 7] 0.000000 True\n",
"non-proportional increment [100010, 100009, 100008, 100007, 100012, 100010, 100007, 100005] 0.000000 False\n",
"Random big numbers or zero [0, 0, 197.98556516655424, 172.2728994418659, 457.79335075776396, 152.4892738791217, 0, 225.23236097569952] 0.309266 False\n",
"max unbalance [0, 0, 0, 0, 10000, 10000, 10000, 10000] 0.263501 False\n",
"proportional increment [1000, 900, 800, 700, 1200, 1000, 700, 500] 0.000000 True\n",
"\n",
"\n",
"--- Incremental noise on signal ---\n",
"0 0.000000 +/- 0.000000\n",
"1 0.000000 +/- 0.000000\n",
"2 0.000749 +/- 0.004237\n",
"3 0.001959 +/- 0.008455\n",
"4 0.003080 +/- 0.013375\n",
"5 0.008437 +/- 0.033195\n",
"6 0.013145 +/- 0.051032\n",
"7 0.016885 +/- 0.059035\n",
"8 0.012466 +/- 0.043463\n",
"9 0.015080 +/- 0.053964\n",
"10 0.015644 +/- 0.059220\n",
"\n",
"\n",
"--- Incremental random noise ---\n",
"0 0.018806 +/- 0.056417\n",
"1 0.027545 +/- 0.088254\n",
"2 0.022396 +/- 0.071375\n",
"3 0.029703 +/- 0.091366\n",
"4 0.026686 +/- 0.085925\n",
"5 0.022741 +/- 0.073748\n",
"6 0.023412 +/- 0.073059\n",
"7 0.024663 +/- 0.084127\n",
"8 0.022264 +/- 0.075595\n",
"9 0.022961 +/- 0.070557\n",
"10 0.025343 +/- 0.080337\n",
"\n",
"\n",
"--- Incremental unbalanced distribution ---\n",
"1 0.230790\n",
"2 0.243396\n",
"3 0.249401\n",
"4 0.252661\n",
"5 0.254701\n",
"6 0.256097\n",
"7 0.257111\n",
"8 0.257881\n",
"9 0.258486\n",
"10 0.258973\n",
"---\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"tests(aggmaxprobhist)"
]
},
{
"cell_type": "markdown",
"id": "9fd5e884",
"metadata": {},
"source": [
"# Real trees "
]
},
{
"cell_type": "code",
"execution_count": 87,
"id": "7641e158",
"metadata": {},
"outputs": [],
"source": [
"def generate_histo(input_file,v):\n",
" t = Tree(input_file) # ouverture du fichier\n",
" l=[]\n",
" for n in t.get_descendants():\n",
" if t.get_distance(n,topology_only=True)==v:# test sur la distance\n",
" l.append(n)\n",
" histof=[]\n",
"\n",
" for x in range(len(l)):# pour toute les occurences dans l\n",
" histo=[]\n",
" for leaf in l[x]: # pour toute les feuilles dans L \n",
" histo.append(leaf)\n",
" histof.append(len(histo))# on recupere le nombre de feuille de chaque sous arbre\n",
" return histof"
]
},
{
"cell_type": "code",
"execution_count": 88,
"id": "dc029957",
"metadata": {},
"outputs": [],
"source": [
"histo70k20=generate_histo(\"results_djeser/CrFBA3_PV00274_0.7_k20.nhx\",3)\n",
"histo80k20=generate_histo(\"results_djeser/CrFBA3_PV00274_0.8_k20.nhx\",3)\n",
"histo90k20=generate_histo(\"results_djeser/CrFBA3_PV00274_0.9_k20.nhx\",3)\n",
"agghisto70k20 = agg_vector(histo70k20)\n",
"agghisto80k20 = agg_vector(histo80k20)\n",
"agghisto90k20 = agg_vector(histo90k20)"
]
},
{
"cell_type": "code",
"execution_count": 89,
"id": "ae740395",
"metadata": {},
"outputs": [],
"source": [
"histo80k3=generate_histo(\"results_djeser/CrFBA3_PV00274_0.8_k3.nhx\",3)\n",
"histo90k3=generate_histo(\"results_djeser/CrFBA3_PV00274_0.9_k3.nhx\",3)\n",
"histo100k3=generate_histo(\"results_djeser/CrFBA3_PV00274_1.0_k3.nhx\",3)\n",
"agghisto80k3 = agg_vector(histo80k3)\n",
"agghisto90k3 = agg_vector(histo90k3)\n",
"agghisto100k3 = agg_vector(histo100k3)"
]
},
{
"cell_type": "code",
"execution_count": 90,
"id": "f95a30d2",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<BarContainer object of 16 artists>"
]
},
"execution_count": 90,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAQDklEQVR4nO3df6zddX3H8edrrb/AGUp6y2qLKywVRaLD3DmUzDgrsZuE8sdYatTcTJZmCyoaNy0zGfEPFjKN02TTpQGkiQTWII5miY6m6sySibvgL0pFiLhSqPQ6549oglbf++N8Gy+3t/Tec86959xPn4+kOef7Od9zzgva+7qf8/11UlVIktryG6MOIEkaPstdkhpkuUtSgyx3SWqQ5S5JDVo96gAAa9eurU2bNo06hiStKPfdd9/3q2pivsfGotw3bdrE9PT0qGNI0oqS5H9O9pibZSSpQZa7JDXIcpekBlnuktQgy12SGmS5S1KDLHdJapDlLkkNstwlqUFjcYaqpJUnH8wJY3W9X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XJ1/AN7HCC/0eZJsfwncWFVPdescXejrtVDuG4DHZi0fZowK9Lgkm4CLgXtHHGW2j9L7B/2rEeeY7XxgBvhkt7nopiRnjjoUQFU9Tm/mdAg4Avyoqu4ZbaoTnFNVR6A3uQDWjTjPybwd+OyoQwAkuQJ4vKq+Puos83gx8AdJ7k3yH0l+b6FPbKHcT3mpg1FL8nzg08C7q+rHo84DkORy4GhV3TfqLHOsBl4JfKKqLgZ+yug2LTxNt/16G3Ae8ELgzCRvHW2qlSfJB+htsrxtDLKcAXwA+NtRZzmJ1cAaept1/xrYkyzsMpotlPtYX+ogybPoFfttVXXXqPPMcilwRZLv0tuU9foknxptJKD393m4qo5/wrmTXtmPgzcAj1bVTFX9ArgLeM2IM831ZJL1AN3tgj/GL4ckU8DlwFtqPE6y+R16v6y/3v0sbATuT/JbI031a4eBu6rnK/Q+ZS9oh28L5T62lzrofsPeDBysqo+MOs9sVXVdVW2sqk30/p99vqpGPgutqu8BjyW5oBvaAjw4wkizHQIuSXJG93e7hTHZ2TvLXmCquz8F3D3CLE+TZCvwfuCKqvrZqPMAVNU3q2pdVW3qfhYOA6/s/h2Og38FXg+Q5MXAs1ng1StXfLl3O2iOX+rgILBnmS51sBCXAm+jNyv+Wvfnj0cdagV4J3Bbkm8Avwv83Wjj9HSfJu4E7ge+Se/nZ2SnrSe5Hfgv4IIkh5NcDdwIXJbkYXpHf9w4Rtn+EfhNYF/3s/DPY5JrLJwk2y3A+d3hkXcAUwv9xOPlBySpQSt+5i5JOpHlLkkNstwlqUGWuyQ1yHKXpAZZ7pLUIMtdkhr0//yGKcRs2GlBAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"from matplotlib import pyplot as plt\n",
"X = np.arange(len(histo70k20))\n",
"plt.bar(X + 0.00, histo70k20, color = 'b', width = 0.25)\n",
"plt.bar(X + 0.25, histo80k20, color = 'r', width = 0.25)\n",
"plt.bar(X + 0.50, histo90k20, color = 'g', width = 0.25)"
]
},
{
"cell_type": "code",
"execution_count": 91,
"id": "8a4dd3b8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.8814593234696813\n",
"0.7869731847259129\n",
"0.4027629892694329\n"
]
}
],
"source": [
"print(aggmaxprobhist(histo70k20, histo80k20))\n",
"print(aggmaxprobhist(histo70k20, histo90k20))\n",
"print(aggmaxprobhist(histo80k20, histo90k20))"
]
},
{
"cell_type": "code",
"execution_count": 92,
"id": "6c2ec90b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<BarContainer object of 16 artists>"
]
},
"execution_count": 92,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAASPUlEQVR4nO3df6zldX3n8edrQd1Va8Tlwk6B7oAZ2aKxQ3OXdZdorNQ6dQ1os3aHdMnsyu7oBrq6td2CJqW2oSGtP9qkq2aUWdgUQSKwko26TlgjaVK1F0QcHCmgFC7MztxqW01t6A6++8f53ni491zumfNjzpnPPB/JyTnnc77fc15w577u937u90eqCklSW/7BrANIkibPcpekBlnuktQgy12SGmS5S1KDTp51AIBTTz21tm7dOusYknRcueeee/6iqhYGvTYX5b5161aWlpZmHUOSjitJ/nyj15yWkaQGWe6S1CDLXZIaZLlLUoMsd0lqkOUuSQ2y3CWpQZa7JDXIcpekBs3FEaqSxpOsHyvWDHphnhOKW+6S1CDLXZIaZLlLUoMsd0lq0KblnuSsJF9IciDJA0ne2Y2/JMm+JA9196f0rXN1koeTPJjkDdP8D5AkrTfMlvsR4N1V9ZPAq4ArkpwHXAXcVVXbgLu653Sv7QReDuwAPpzkpGmEly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Z5+lXVVdX1ZlVtZXe/7P/W1Uz3wqtqv8HPJ7k3G7oIuAbM4zU7zHgVUme331tL2JO/tjb505gV/d4F/DpGWZ5hu4CPr8OXFxVP5h1HoCq+npVnVZVW7vvhWXgp7t/h/PgfwGvA0jyMuC5DHn2yuO+3Ls/0Kye6uAAcOsxOtXBMC4ELqO3VXxfd3vjrEMdB34ZuCnJ/cB24HdmG6en+23iU8C9wNfpff/M7LD1JDcDfwKcm2Q5yeXAdcDrkzxEb++PmVwBbYNsfwj8GLCv+1746JzkmgsbZNsLnNPtHnkLsGvY33g8/YAkNei433KXJK1nuUtSgyx3SWqQ5S5JDbLcJalBlrskNchyl6QG/T0eEhX1C1t3fgAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.bar(X + 0.00, histo80k3, color = 'b', width = 0.25)\n",
"plt.bar(X + 0.25, histo90k3, color = 'r', width = 0.25)\n",
"plt.bar(X + 0.50, histo100k3, color = 'g', width = 0.25)"
]
},
{
"cell_type": "code",
"execution_count": 93,
"id": "1540d594",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.0\n",
"0.9798736319567721\n",
"0.9798736319567721\n"
]
}
],
"source": [
"print(aggmaxprobhist(histo80k3, histo90k3))\n",
"print(aggmaxprobhist(histo80k3, histo100k3))\n",
"print(aggmaxprobhist(histo90k3, histo100k3))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment