% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diffusion.R
\name{pseudotimeDetermineLogistic}
\alias{pseudotimeDetermineLogistic}
\title{Determine logistic parameters for biasing transition matrix}
\usage{
pseudotimeDetermineLogistic(
  object,
  pseudotime,
  optimal.cells.forward,
  max.cells.back,
  pseudotime.direction = "<",
  do.plot = T,
  print.values = T
)
}
\arguments{
\item{object}{An URD object}

\item{pseudotime}{(Character) Name of pseudotime to use for biasing (i.e. a column name of \code{@pseudotime})}

\item{optimal.cells.forward}{(Numeric) The number of cells in the direction specified by \code{pseudotime.direction} at which the logistic should reach 1-\code{asymptote}.}

\item{max.cells.back}{(Numeric) The number of cells in the direction opposite from that specified by \code{pseudotime.direction} at which the logistic should reach \code{asymptote}.}

\item{pseudotime.direction}{(Character: "<" or ">") Which direction to bias the transition probabilities (\code{"<"} is default, which biases them to move toward cells with younger pseudotime.)}

\item{do.plot}{(Logical) Should the logistic function be plotted?}

\item{print.values}{(Logical) Should the values determined for the logistic be printed?}
}
\value{
A list: Logistic parameters to use in \code{\link{pseudotimeWeightTransitionMatrix}}.
}
\description{
This determines the slope and inflection point of the logistic function used
to bias the transition probabilities, based on the pseudotimes of cells in the
data.
}
\details{
For determining the developmental trajectories, it is critical to ensure that when walks reach a
branchpoint in the data, they continue toward the root, rather than turning down the path toward
a different differentiated population. Thus, we convert the undirected graph defined by the 
transition probabilities into a directed graph where transitions are much more likely to 
earlier or equally pseudotimed cells than to later pseudotimed cells (which would 
correspond to a different, more differentiated branch). To do this, we biased the 
transition probabilities between each pair of cells by multiplying the original 
transition probabilities with a factor that ranges from 0 to 1. These factors are 
obtained by transforming the difference in pseudotime between the two cells with 
a logistic function. This function uses the average difference in pseudotime 
between cells that are \code{optimal.cells.forward} and \code{max.cells.back} 
apart (when all cells in the data are ranked according to pseudotime) to determine
\code{k} and \code{x0} for the logistic function.
}
\examples{
# Determine parameters of logistic function
diffusion.logistic <- pseudotimeDetermineLogistic(object, "pseudotime", optimal.cells.forward = 40, max.cells.back = 80, pseudotime.direction = "<", do.plot = T, print.values = T)

# Generate biased transition matrix
biased.tm <- pseudotimeWeightTransitionMatrix(object, pseudotime = "pseudotime", logistic.params = diffusion.logistic, pseudotime.direction = "<")

# Simulate random walks
these.walks <- simulateRandomWalk(start.cells = tip.10.cells, transition.matrix = biased.tm, end.cells = root.cells, n = 50000, end.visits = 1, verbose.freq = 2500, max.steps = 5000)

# Process walks into visitation frequency
object <- processRandomWalks(object, walks = these.walks, walks.name = "10", verbose = F)

}
