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/vejnar/notebooks
11 May 2023, 10:34:40 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
Revision 3cac0e8f80f0b5b1aaec2b9ce93f6ea1e77da9a7 authored by vejnar on 01 April 2023, 20:34:50 UTC, committed by vejnar on 01 April 2023, 20:34:50 UTC
Add license
1 parent 7f7e868
  • Files
  • Changes
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • 3cac0e8f80f0b5b1aaec2b9ce93f6ea1e77da9a7
    No releases to show
  • f83a655
  • /
  • deseq_from_python
  • /
  • de.py
Raw File Download
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 ...

Permalinks

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.

  • revision
  • directory
  • content
  • snapshot
origin badgerevision badge
swh:1:rev:3cac0e8f80f0b5b1aaec2b9ce93f6ea1e77da9a7
origin badgedirectory badge Iframe embedding
swh:1:dir:9f0a8c010b85416e55e08f27f4f6e5947979d4e5
origin badgecontent badge Iframe embedding
swh:1:cnt:03abcee442fbc48db4d32460f309fcd1d94d9b5d
origin badgesnapshot badge
swh:1:snp:7484321729ee73b4a6f6b817de059dcb81377a11
Citations

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.

  • revision
  • directory
  • content
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 3cac0e8f80f0b5b1aaec2b9ce93f6ea1e77da9a7 authored by vejnar on 01 April 2023, 20:34:50 UTC
Add license
Tip revision: 3cac0e8
de.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# # Gene differential expression with DESeq2 from Python
#
# Author: Charles E. Vejnar (charles.vejnar@gmail.com)
#
# **Requirements**
#
# * Python with [Matplotlib](https://matplotlib.org)
# * Download gene expression data [dev_timecourse_zebrafish_vejnar_giraldez_count_900_gene_protein_coding_v11.csv.xz](https://data.giraldezlab.org/pub/vejnar_et_al_2019_genome_research/dev_timecourse_gene_count/dev_timecourse_zebrafish_vejnar_giraldez_count_900_gene_protein_coding_v11.csv.xz). More samples are [available](https://www.giraldezlab.org/data/vejnar_et_al_2019_genome_research/).
#
# Please cite relevant papers if you use this tutorial and/or data:
# * [Genome wide analysis of 3' UTR sequence elements and proteins regulating mRNA stability during maternal-to-zygotic transition in zebrafish](https://pubmed.ncbi.nlm.nih.gov/31227602/) Vejnar et al, 2019
# * [Moderated estimation of fold change and dispersion for RNA-seq data with DESeq2](https://pubmed.ncbi.nlm.nih.gov/25516281/) Love et al, 2014
#

import subprocess

import numpy as np
import pandas as pd

# Path to gene count
path_count = 'dev_timecourse_zebrafish_vejnar_giraldez_count_900_gene_protein_coding_v11.csv.xz'
# Minimum read count per condition
min_count = 1
# Method for adjusting P-values
p_adjust = 'fdr'
# Column separator
col_sep = ' '
# Define DE tests
tests = [{'name': 'WT shield vs a-Am',
          'samples1': ['WT shield pA B1', 'WT shield pA B2'],
          'samples2': ['WT a-Am shield pA B1', 'WT a-Am shield pA B2']}]

# Open main time-course
dcount = pd.read_csv(path_count, index_col=0)
# Keep only zebrafish
dcount.drop([i for i in dcount.index if not i.startswith('ENSDAR')], inplace=True)

de_data = [dcount.loc[:,['gene_name', 'gene_length']]]
for test in tests:
    # Get samples & Remove total
    dcount_cond = dcount.loc[:, test['samples1']+test['samples2']]
    # Selection min_count per condition
    sel_count = np.all([np.any(dcount_cond.loc[:, test['samples1']] >= min_count, axis=1), np.any(dcount_cond.loc[:, test['samples2']] >= min_count, axis=1)], axis=0)
    # Round (DESeq2 requires counts i.e. integers) & Output
    dcount_cond.loc[sel_count, :].round().to_csv('count.csv', index=True)

    # Conditions
    pd.DataFrame([test['samples1']+test['samples2'], ['a']*len(test['samples1']) + ['b']*len(test['samples2'])], index=['', 'condition']).T.to_csv('cond.csv', index=False)

    # Run DESeq
    subprocess.run(['Rscript','run_deseq.r', 'count.csv', 'cond.csv', 'de.csv', p_adjust], check=True)

    # Get results
    de = pd.read_csv('de.csv', index_col=0)
    de.rename(columns=lambda x: test['name']+col_sep+x, inplace=True)
    de_data.append(de)

# Merge and save
dds = pd.concat(de_data, join='inner', axis=1)
dds.to_csv('de.csv')
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

Software Heritage — Copyright (C) 2015–2025, 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— Contact— JavaScript license information— Web API

back to top