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/emkcosta/KillifishAutomaticFeederPaper
07 December 2022, 14:04:35 UTC
  • Code
  • Branches (2)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/add-license-1
    • refs/heads/main
    No releases to show
  • 336b4b1
  • /
  • Fig5_SuppFig5
  • /
  • R_scripts
  • /
  • 2_getCombinedCountMatrix_220805_codechk.pl
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 ...

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:6b04fe0d367037685e74f17da4f63c546173ce91
origin badgedirectory badge
swh:1:dir:028f620e76f50bc8271b25bcf22af47ae6b46d84
origin badgerevision badge
swh:1:rev:451bc5d78cd266a00b53612585d201d404f73920
origin badgesnapshot badge
swh:1:snp:a9f2e10f0b2ec00bc74865a9a1af5fd0004baa95

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
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: 451bc5d78cd266a00b53612585d201d404f73920 authored by Emma on 24 October 2022, 20:33:32 UTC
Delete SuppFig2 directory
Tip revision: 451bc5d
2_getCombinedCountMatrix_220805_codechk.pl
# Title:  Make a Exon TPM, Counts, GeneLengths supermatrix for all samples
# Author: Jingxun Chen
# Date: code compiled on 20220805
# Related publication: Andrew McKay, Emma K. Costa, and Jingxun Chen, eLife, 2022
#

use strict;
use warnings;

## -------------------------------------------------------------------------------------------------------------------
my $designfile = '/Users/jingxun/Documents/ALDR_Feeder_220318/R/Code_check/GetCounts/Input/DRexp20211219ExperimentDesign.csv';
my $tpmfile = '/Users/jingxun/Documents/ALDR_Feeder_220318/R/Code_check/GetCounts/Output';
my $outct = 'Counts_ALDR_220325.csv';
my $outtpm = 'TPM_ALDR_220325.csv';
my $outlen = 'GeneLengths_ALDR_220325.csv';
## -------------------------------------------------------------------------------------------------------------------

# Open design file to see which files to read
open DN, $designfile or die $!;
my @design = <DN>;
shift @design;

my @libOrder;
my %sampleNames; # understandable names for samples
foreach (@design){
	
	my @line = split ',', $_;
	map {$_=~s/\n//g} @line;
	
	print "$line[1]\n";
	push @libOrder, $line[1];
	if ($line[0] =~/^\d+/g){$line[0] = "X$line[0]"} # Append an X if name starts with number because R won't allow it
	$sampleNames{$line[1]} = $line[0]; # understandable names for samples
}
my $lastlib = $libOrder[-1];
print "Last library: $lastlib\n";

my %SuperMatrix;
my %Idlist;

foreach my $lib (@libOrder){
	
	print "$tpmfile/$lib\_counts.csv\t";
	open FH, "$tpmfile/$lib\_counts.csv" or die "$tpmfile/$lib\_counts.csv ", $!;
	my @file = <FH>;
	close (FH);	
	shift @file;
	print scalar @file, "\n";
	
	foreach (@file){

		my @line = split ",", $_;
		map {$_=~s/\n//g} @line;	
		die "Lengths differ at $line[0] $lib" if ((exists $Idlist{$line[0]}) && $Idlist{$line[0]} != $line[1]);
		$Idlist{$line[0]} = $line[1]; # global id list common to all samples and their lengths
		$SuperMatrix{$line[0]}{$lib} = [$line[2], $line[3]]; # Counts and TPM
	} 
}

print "Total gene: ", scalar keys %Idlist, "\n";

# print to a file
open CT, ">$outct" or die $!;
open TPM, ">$outtpm" or die $!;
open LEN, ">$outlen" or die $!;

# Print header with proper sample names
foreach (@libOrder){
	if ($_ eq $lastlib){ # If last library print without comma
		print CT "\"$sampleNames{$_}\""; print TPM "\"$sampleNames{$_}\""; print LEN "\"$sampleNames{$_}\"";
	}
	else {
		print CT "\"$sampleNames{$_}\","; print TPM "\"$sampleNames{$_}\","; print LEN "\"$sampleNames{$_}\",";
	}
}
print CT "\n"; print TPM "\n"; print LEN "\n";

foreach my $gene (keys %Idlist){
	
	print CT "\"$gene\","; print LEN "\"$gene\",";	print TPM "\"$gene\",";
	
	foreach my $lib (@libOrder){
		
		if ($lib eq $lastlib){ # If last library print without comma
			if (exists $SuperMatrix{$gene}{$lib}){
				print LEN "$Idlist{$gene}";
				print CT "$SuperMatrix{$gene}{$lib}[0]";
				print TPM "$SuperMatrix{$gene}{$lib}[1]";

			}
			else {
				print LEN "$Idlist{$gene},";
				print CT "0,";
				print TPM "0,";			
			}
		}
		else {
			if (exists $SuperMatrix{$gene}{$lib}){
				print LEN "$Idlist{$gene},";
				print CT "$SuperMatrix{$gene}{$lib}[0],";
				print TPM "$SuperMatrix{$gene}{$lib}[1],";

			}
			else {
				print LEN "$Idlist{$gene},";
				print CT "0,";
				print TPM "0,";
			}
		}
	}
print CT "\n"; print TPM "\n"; print LEN "\n";
}
close (CT); close (TPM); close (LEN);




back to top

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— Content policy— Contact— JavaScript license information— Web API