Make plot highlighting record datasets over time#
from mizani.formatters import comma_format
import pandas as pd
import plotnine as p
%pylab inline
%config InlineBackend.figure_formats = ['retina']
from datetime import datetime
%pylab is deprecated, use %matplotlib inline and import the required libraries.
Populating the interactive namespace from numpy and matplotlib
data = pd.read_csv('https://nxn.se/single-cell-studies/data.tsv', sep='\t', storage_options = {'User-Agent': ''})
data['Date'] = data['Date'].pipe(pd.to_datetime, format='%Y%m%d')
data['Reported cells total'] = data['Reported cells total'].str.replace(',', '').map(float)
df = data.query('Measurement == "RNA-seq"').reset_index(drop = True)
df = df.sort_values('Date')
df['Record breaker'] = False
record = 0
for n, row in df.iterrows():
if row['Reported cells total'] > record:
df.loc[n, 'Record breaker'] = True
record = row['Reported cells total']
display(df.query('`Record breaker` == True'));
| Shorthand | DOI | Authors | Journal | Title | Date | bioRxiv DOI | Reported cells total | Organism | Tissue | ... | Cell clustering | Pseudotime | RNA Velocity | PCA | tSNE | H5AD location | Isolation | BC --> Cell ID _OR_ BC --> Cluster ID | Number individuals | Record breaker | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Tang et al NMeth | 10.1038/NMETH.1315 | Fuchou Tang, Catalin Barbacioru, Yangzhou Wang... | Nat Methods | mRNA-Seq whole-transcriptome analysis of a sin... | 2009-04-06 | - | 5.0 | Mouse | Oocyte | ... | No | No | No | No | No | NaN | Pipetting (Manual picking) | NaN | NaN | True |
| 1 | Tang et al CSC | 10.1016/j.stem.2010.03.015 | Fuchou Tang, Catalin Barbacioru, Siqin Bao, Ca... | Cell Stem Cell | Tracing the Derivation of Embryonic Stem Cells... | 2010-05-07 | - | 34.0 | Mouse | Embryo | ... | NaN | NaN | No | Yes | NaN | NaN | NaN | NaN | NaN | True |
| 2 | Islam et al GR | 10.1101/gr.110882.110 | S. Islam, U. Kjallquist, A. Moliner, P. Zajac,... | Genome Research | Characterization of the single-cell transcript... | 2011-05-05 | - | 85.0 | Mouse | Culture | ... | Yes | No | NaN | Yes | No | NaN | Pipetting (Manual picking) | NaN | NaN | True |
| 6 | Hashimshony et al CR | 10.1016/j.celrep.2012.08.003 | Tamar Hashimshony, Florian Wagner, Noa Sher, I... | Cell Reports | CEL-Seq: Single-Cell RNA-Seq by Multiplexed Li... | 2012-08-30 | - | 96.0 | C elegans | Embryo | ... | No | No | NaN | No | No | NaN | Pipetting (Manual picking) | NaN | NaN | True |
| 11 | Yan et al NSMB | 10.1038/nsmb.2660 | Liying Yan, Mingyu Yang, Hongshan Guo, Lu Yang... | Nat Struct Mol Biol | Single-cell RNA-Seq profiling of human preimpl... | 2013-08-09 | - | 124.0 | Human | Culture | ... | Yes | No | NaN | Yes | No | NaN | NaN | NaN | NaN | True |
| 17 | Islam et al NMeth | 10.1038/nmeth.2772 | Saiful Islam, Amit Zeisel, Simon Joost, Gioele... | Nat Methods | Quantitative single-cell RNA-seq with unique m... | 2013-12-22 | - | 192.0 | Mouse | Culture | ... | No | No | NaN | No | No | NaN | IFC Capture | NaN | NaN | True |
| 18 | Deng et al Science | 10.1126/science.1245316 | Q. Deng, D. Ramskold, B. Reinius, R. Sandberg | Science | Single-Cell RNA-Seq Reveals Dynamic, Random Mo... | 2014-01-09 | - | 269.0 | Mouse | Embryo | ... | No | No | No | Yes | No | NaN | NaN | NaN | NaN | True |
| 19 | Jaitin et al Science | 10.1126/science.1247651 | D. A. Jaitin, E. Kenigsberg, H. Keren-Shaul, N... | Science | Massively Parallel Single-Cell RNA-Seq for Mar... | 2014-02-14 | - | 4468.0 | Mouse | Spleen | ... | Yes | No | NaN | No | No | NaN | Sorting (FACS) | NaN | NaN | True |
| 20 | Soumillon et al bioRxiv | 10.1101/003236 | Magali Soumillon, Davide Cacchiarelli, Stefan ... | bioRxiv | Characterization of directed differentiation b... | 2014-03-10 | 10.1101/003236 | 12832.0 | Human | Culture | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | True |
| 38 | Fan et al Science | 10.1126/science.1258367 | H. Christina Fan, Glenn K. Fu, Stephen P. A. F... | Science | Combinatorial labeling of single cells for gen... | 2015-02-05 | - | 15000.0 | Human | Blood, Culture | ... | Yes | No | NaN | Yes | No | NaN | Picowell deposition | NaN | 2 | True |
| 48 | Macosko et al Cell | 10.1016/j.cell.2015.05.002 | Evan Z. Macosko, Anindita Basu, Rahul Satija, ... | Cell | Highly Parallel Genome-wide Expression Profili... | 2015-05-21 | - | 44808.0 | Human, Mouse | Eye | ... | Yes | No | No | Yes | Yes | NaN | Nanodroplet dilution | SCP301 | NaN | True |
| 158 | Adamson et al Cell | 10.1016/j.cell.2016.11.048 | Britt Adamson, Thomas M. Norman, Marco Jost, M... | Cell | A Multiplexed Single-Cell CRISPR Screening Pla... | 2016-12-15 | - | 86000.0 | Human | Culture | ... | NaN | NaN | NaN | NaN | Yes | NaN | NaN | NaN | NaN | True |
| 160 | Dixit et al Cell | 10.1016/j.cell.2016.11.038 | Atray Dixit, Oren Parnas, Biyu Li, Jenny Chen,... | Cell | Perturb-Seq: Dissecting Molecular Circuits wit... | 2016-12-15 | - | 200000.0 | Human, Mouse | Culture | ... | NaN | NaN | NaN | NaN | No | NaN | Nanodroplet dilution | NaN | NaN | True |
| 168 | Zheng et al NComm | 10.1038/ncomms14049 | Grace X. Y. Zheng, Jessica M. Terry, Phillip B... | Nat Commun | Massively parallel digital transcriptional pro... | 2017-01-16 | 10.1101/065912 | 250000.0 | Human, Mouse | Blood | ... | Yes | NaN | NaN | Yes | Yes | NaN | Nanodroplet dilution | NaN | 5 | True |
| 291 | Han et al Cell | 10.1016/j.cell.2018.02.001 | Xiaoping Han, Renying Wang, Yincong Zhou, Liji... | Cell | Mapping the Mouse Cell Atlas by Microwell-Seq | 2018-02-23 | - | 400000.0 | Mouse | Bladder, Bone marrow, Brain, Kidney, Liver, Lu... | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | True |
| 376 | Zeisel et al Cell | 10.1016/j.cell.2018.06.021 | Amit Zeisel, Hannah Hochgerner, Peter Lönnerbe... | Cell | Molecular Architecture of the Mouse Nervous Sy... | 2018-08-09 | 10.1101/294918 | 509876.0 | Mouse | Brain | ... | Yes | NaN | NaN | Yes | Yes | NaN | NaN | NaN | NaN | True |
| 377 | Saunders et al Cell | 10.1016/j.cell.2018.07.028 | Arpiar Saunders, Evan Z. Macosko, Alec Wysoker... | Cell | Molecular Diversity and Specializations among ... | 2018-08-09 | 10.1101/299081 | 690000.0 | Mouse | Brain | ... | Yes | NaN | NaN | NaN | NaN | gs://h5ad/2018-08-Saunders-et-al-Cell | NaN | NaN | NaN | True |
| 445 | Schmeidel et al Cell | 10.1016/j.cell.2018.10.022 | Benjamin J. Schmiedel, Divya Singh, Ariel Madr... | Cell | Impact of Genetic Polymorphisms on Human Immun... | 2018-11-15 | NaN | 1000000.0 | Human | Blood | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 91 | True |
| 525 | Cao et al Nature | 10.1038/s41586-019-0969-x | Junyue Cao, Malte Spielmann, Xiaojie Qiu, Xing... | Nature | The single-cell transcriptional landscape of m... | 2019-02-20 | - | 2058652.0 | Mouse | Embryo | ... | NaN | NaN | NaN | NaN | NaN | https://storage.googleapis.com/h5ad/2019-02-Ca... | NaN | NaN | NaN | True |
| 555 | Rodriques et al Science | 10.1126/science.aaw1219 | Samuel G. Rodriques, Robert R. Stickels, Aleks... | Science | Slide-seq: A scalable technology for measuring... | 2019-03-28 | 10.1101/563395 | 2522640.0 | Mouse | Brain | ... | NaN | NaN | NaN | NaN | NaN | https://storage.googleapis.com/h5ad/2019-03-Ro... | Spatial RNA coordinates | NaN | NaN | True |
| 1222 | Cao et al Science | 10.1126/science.aba7721 | Junyue Cao, Diana R. O’Day, Hannah A. Pliner, ... | Science | A human cell atlas of fetal gene expression | 2020-11-13 | NaN | 4062980.0 | Human | Adrenal gland, Brain, Eye, Heart, Intestine, K... | ... | Yes | Yes | No | Yes | No | https://storage.googleapis.com/h5ad/10.1126-sc... | NaN | NaN | 121 | True |
| 1787 | Langlieb et al Nature | 10.1038/s41586-023-06818-7 | Jonah Langlieb, Nina S. Sachdev, Karol S. Bald... | Nature | The molecular cytoarchitecture of the adult mo... | 2023-12-13 | 10.1101/2023.03.06.531307 | 4388420.0 | Mouse | Brain | ... | Yes | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | True |
| 1800 | Qiu et al Nature | 10.1038/s41586-024-07069-w | Chengxiang Qiu, Beth K. Martin, Ian C. Welsh, ... | Nature | A single-cell time-lapse of mouse prenatal dev... | 2024-02-14 | 10.1101/2023.04.05.535726 | 12400000.0 | Mouse | NaN | ... | Yes | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | True |
| 1836 | Zhang et al Science | 10.1126/science.adn3949 | Zehao Zhang, Chloe Schaefer, Weirong Jiang, Zi... | Science | A panoramic view of cell population dynamics i... | 2024-11-28 | 10.1101/2024.03.01.583001 | 21786931.0 | Mouse | Brain, Lung, Heart, Liver, Kidney, Muscle, Sto... | ... | Yes | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | True |
| 1863 | Zhang et al bioRxiv | 10.1101/2025.02.20.639398 | Jesse Zhang, Airol A Ubas, Richard de Borja, V... | bioRxiv | Tahoe-100M: A Giga-Scale Single-Cell Perturbat... | 2025-02-24 | 10.1101/2025.02.20.639398 | 152915189.0 | Human | Culture | ... | No | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 50 | True |
25 rows × 29 columns
df.columns
Index(['Shorthand', 'DOI', 'Authors', 'Journal', 'Title', 'Date',
'bioRxiv DOI', 'Reported cells total', 'Organism', 'Tissue',
'Technique', 'Data location', 'Panel size', 'Measurement',
'Cell source', 'Disease', 'Contrasts', 'Developmental stage',
'Number of reported cell types or clusters', 'Cell clustering',
'Pseudotime', 'RNA Velocity', 'PCA', 'tSNE', 'H5AD location',
'Isolation', 'BC --> Cell ID _OR_ BC --> Cluster ID',
'Number individuals', 'Record breaker'],
dtype='object')
df.shape
(1899, 29)
p.options.figure_size = (20, 7)
fig = (
p.ggplot(p.aes(x = 'Date', y = 'Reported cells total'), df)
+ p.geom_point(color = 'lightgrey')
+ p.geom_point(size = 2, color = 'black', data = df.query('`Record breaker` == True'))
+ p.geom_text(
p.aes(label = 'Shorthand'),
data = df.query('`Record breaker` == True'),
size = 8,
ha = 'right',
va = 'bottom'
)
+ p.scale_y_log10(breaks = [1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7], limits = (1, 1e8), labels = comma_format())
+ p.scale_x_datetime()
+ p.theme_minimal()
+ p.labs(title = 'Cells per study over time', x = 'Publication date')
)
fig
/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/plotnine/layer.py:372: PlotnineWarning: geom_point : Removed 449 rows containing missing values.
/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/plotnine/layer.py:372: PlotnineWarning: geom_point : Removed 1 rows containing missing values.
/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/plotnine/layer.py:372: PlotnineWarning: geom_text : Removed 1 rows containing missing values.
p.options.figure_size = (20, 7)
fig = (
p.ggplot(p.aes(x = 'Date', y = 'Reported cells total'), df)
+ p.geom_point(color = 'lightgrey')
+ p.geom_point(size = 2, color = 'black', data = df.query('`Record breaker` == True'))
+ p.geom_text(
p.aes(label = 'Shorthand'),
data = df.query('`Record breaker` == True'),
size = 8,
adjust_text = {
'expand_points': (1, 1.1),
'expand_text': (1.5, 1.05),
'arrowprops': {
'arrowstyle': '-',
'color': 'black',
'lw': 0.5,
'zorder': 0
},
'autoalign': 'y',
}
)
+ p.scale_y_log10(breaks = [1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7], limits = (1, 1e8), labels = comma_format())
+ p.scale_x_datetime()
+ p.theme_minimal()
+ p.labs(title = 'Cells per study over time', x = 'Publication date')
)
fig
/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/plotnine/layer.py:372: PlotnineWarning: geom_point : Removed 449 rows containing missing values.
/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/plotnine/layer.py:372: PlotnineWarning: geom_point : Removed 1 rows containing missing values.
/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/plotnine/layer.py:372: PlotnineWarning: geom_text : Removed 1 rows containing missing values.
Looks like you are using a tranform that doesn't support FancyArrowPatch, using ax.annotate instead. The arrows might strike through texts. Increasing shrinkA in arrowprops might help.