Giter VIP home page Giter VIP logo

metacell.flow's Introduction

metacell.flow

The goal of metacell.flow is to infer differentiation flow models from single cell RNA-seq data and metacell models representing it, with time tags per cell. Potential techniques for inferring or sampling time tags will be under invesigation. This package is still in research mode.

Installation

You can install the released version of metacell.flow from github with:

remotes::install_github("tanaylab/metacell.flow")

Example

library("metacell")
library("metacell.flow")
scdb_init("scrna_db/", force_reinit=T)
scdb_flow_init()
tgconfig::override_params("config/netflow.yaml","metacell")

example_leak_table_sing_emb = function(mc_id, leak_emb_endo, leak_exe_endo) 
{
  mc = scdb_mc(mc_id)
  legc = log2(mc@e_gc + 1e-5)
  mc_leak = rep(0,ncol(legc))
  
  # first separation embryonic endoderm (including node/notochord) from meso/-ectoderm 
  x1 = -16
  y1 = -12
  x2 = -12
  y2 = -16
  
  b_emb_endo = (y2 - y1)/(x2 - x1)
  a_emb_endo = (y1*x2 - y2*x1)/(x2 - x1)
  
  f_endo = (legc["Foxa1",]  > a_emb_endo + b_emb_endo*legc["Foxa2",])
  mc_leak[f_endo] = leak_emb_endo
  
  # second separation extraembryonic from embryonic endoderm uses Apoe
  x1 = -8.4
  y1 = -14
  x2 = -11
  y2 = -8.4
  
  b_exe_endo = (y2 - y1)/(x2 - x1)
  a_exe_endo = (y1*x2 - y2*x1)/(x2 - x1)
  f_exe = (legc["Ttr",]  > a_exe_endo + b_exe_endo*legc["Apoe",])
  mc_leak[f_exe] = leak_exe_endo
  return(mc_leak)
}

mc_leak = example_leak_table_sing_emb(
            mc_id = "sing_emb_wt10_recolored",
            leak_emb_endo = 0.12,
            leak_exe_endo = 0.17)

write.table(as.data.frame(mc_leak), sep="\t", quote=F, file="scrna_db/leak.sing_emb_wt10_recolored.txt")

mat_id = "sing_emb_wt10"
mc_id = "sing_emb_wt10_recolored"
mgraph_id = "sing_emb_wt10_logist"
net_id = "sing_emb_wt10_logist"

mat = scdb_mat(mat_id)
md = mat@cell_metadata
cell_time = md[,"age_group"]

mgraph = scdb_mgraph(mgraph_id)
names(cell_time) = rownames(md)

leak_fn = "scrna_db/leak.sing_emb_wt10_recolored.txt"

mcell_mctnet_from_mgraph(net_id, 
                                mgraph_id,
                                cell_time,
                                leak_fn,
                            t_exp = 1,
                                T_cost = 1e+5,
                                capacity_var_factor = NULL,
                                off_capacity_cost1 = 1,
                                off_capacity_cost2 = 1000,
                                k_norm_ext_cost = 1,
                                k_ext_norm_cost = 1,
                                k_ext_ext_cost = 1)

##now generate the flow itself

flow_id = "sing_emb_wt10_logist"
fig_dir = "figs/"

flow_tolerance = 0.01

network_color_ord = NULL
  
message("generate flows")

mcell_new_mctnetflow(flow_id, net_id, 
                            init_mincost = T, flow_tolerance=0.01)

message("solved network flow problem")

mcf = scdb_mctnetflow(flow_id)
  
#compute propagatation forward and background
mcf = mctnetflow_comp_propagation(mcf)
  
#adding back the object with the network and flows
scdb_add_mctnetflow(flow_id, mcf)

metacell.flow's People

Contributors

aviezerl avatar ofirr avatar talsokolov avatar

Watchers

 avatar  avatar

Forkers

metaddict

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.