Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/functional-dark-side/vanni_et_al-figures
21 May 2026, 23:57:35 UTC
  • Code
  • Branches (2)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/v1.0
    No releases to show
  • e496c79
  • /
  • scripts
  • /
  • filter-mg-samples.R
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:bce7249dc45510185f0f4468547842a7267ab464
origin badgedirectory badge
swh:1:dir:8385ec8dc6bd20b456accdd7d72240fc46e090a8
origin badgerevision badge
swh:1:rev:4c8f60e761bcac0dd02f17d2fdbb65dcaf75707a
origin badgesnapshot badge
swh:1:snp:a1ee75a79407c53b52d16d9a8aa9303c0e118f6f

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 4c8f60e761bcac0dd02f17d2fdbb65dcaf75707a authored by genomewalker on 12 August 2020, 09:35:52 UTC
Fixed Fig6
Tip revision: 4c8f60e
filter-mg-samples.R
library(tidyverse)
library(RSQLite)

source("lib/libs.R")


# Initialize DB
db <- "data/filter-mg-samples.sqlite"
con <- RSQLite::dbConnect(RSQLite::SQLite(), db)

# Get assemblies
HMP1_I_assm <- tbl(con, "hmp1_I_assm") %>%
  collect()

# Read gene data
gene_data <- tbl(con, "gene_data") %>%
  collect()

# Read HMP QC samples
HMP_qc <- tbl(con, "hmp_qc") %>%
  collect()

# Get all cdata
# HMP1-I date = 2011
# HMP1-II date = 2014
HMP_cdata <- tbl(con, "hmp_cdata") %>%
  collect()


# Samples that had a problem during mapping to the assemblies
HMP_nocoverage <- tbl(con, "hmp_nocoverage") %>%
  collect()

# Get bad HMP1-I samples
# 745 samples
HMP1_I <- HMP_cdata %>%
  inner_join(HMP1_I_assm)

# 690 HQ
HMP_bad <- HMP1_I %>%
  filter(phase == "HMP1-I") %>%
  filter(!(label %in% HMP_qc$label))


# Filter out bad samples
gene_data_filt <- gene_data %>%
  filter(!(label %in% HMP_bad$label))

gene_data %>%
  group_by(study) %>%
  count()

#filtering out bad HMP
gene_data_filt %>%
  group_by(study) %>%
  count()

nsamples <- gene_data_filt %>%
  group_by(study) %>%
  count()

gene_data_filt_summary <- summary(gene_data_filt$n_genes)

ggthemr::ggthemr(palette = "fresh", layout = "scientific")

gene_data_filt %>%
  ggplot(aes(n_genes)) +
  geom_histogram(binwidth = calc_bin_width(log10(gene_data_filt$n_genes)), color = "black", alpha = 0.7) +
  stat_percentile_x(probs = c(0.25, 0.5, 0.75), linetype = 2, color = "#B7144B") +
  stat_percentile_xlab(probs = c(0.25, 0.5, 0.75), hjust = 1, vjust = 1.5, angle = 90, size = 2.2) +
  scale_x_log10(labels = scales::comma) +
  xlab("Number of genes") +
  ylab("Counts") +
  theme(axis.title = element_text(size=7),
        axis.text = element_text(size=6))

# We will keep samples with >= genes than the ones in the first quartile
p25 <- quantile(gene_data_filt$n_genes, probs=0.25)

geneXsample <- gene_data_filt %>%
  filter(n_genes >= p25) %>%
  group_by(study) %>%
  count(sort = TRUE)

# Get final set of samples !!!! ##
samples_list <- gene_data_filt %>%
  filter(n_genes >= p25) %>%
  filter(!(label %in% HMP_nocoverage$label))

dbDisconnect(con)

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API