Git Product home page Git Product logo

Comments (3)

kstreet13 avatar kstreet13 commented on July 21, 2024

Hm, that is little strange.
One thing I can say is that Slingshot treats lineage assignment as a continuous quantity, so each cell has a weight associated with each lineage and the NA values in pseudotime just reflect weights of zero. For the cells assigned to both lineages that look like they should only be on one, what are their weights? If they are relatively small for the more distant lineage, this could potentially be solved by setting a stricter cutoff for inclusion on a lineage (such as a weight >= 0.5), making a few more NAs in the final pseudotime variables.

from slingshot.

ZaZo0o avatar ZaZo0o commented on July 21, 2024

Hello!

I have updated Slingshot as I saw you made modifications on the code.

I created my own function to retrieve the pseudotime for each lineage from the lambda, as it is not yet implemented in the new version (or I missed something...):

get_pseudotime <- function(pseudotime, wthres=wthres){
	pseudoT <- list()
	for(lineage in 1:length(pseudotime@curves))local({
		curve <- pseudotime@curves[[lineage]]
		lambda <- curve$lambda
		weight <- curve$w
		ps <- curve$lambda
		ps[weight < wthres] <- NA
		pseudoT[[lineage]] <<- ps
	})
	df <- t(do.call("rbind",pseudoT))
	colnames(df) <- names(pseudotime@curves)
	return(df)
}

When I set the weight threshold to weight >= 0.9, I have a much neater lineage that fit perfectly the biology (and my previous results with other methods).

And here is my code to plot single gene expression per lineage if you are interested. It is not very optimised but at least it works for me:

plot_gene_per_lineage <- function(rpkm_matrix=rpkm_matrix, pseudotime=pseudotime, gene=gene, condition=condition){
	myplots <- list()
	total_pseudotime <- vector()
	for (lineages in 1:ncol(pseudotime)){
		lineage <- as.vector(pseudotime[,lineages])
		total_pseudotime <- c(total_pseudotime, lineage)
		total_pseudotime <- na.omit(total_pseudotime)
	}
	max_exp <- max(log(rpkm_matrix[rownames(rpkm_matrix) %in% gene,]+1))
	max_pseudotime <- max(total_pseudotime)
	for (lineages in 1:ncol(pseudotime))local({
		i <- lineages
		lineage <- pseudotime[,lineages]
		sub_data <- log(rpkm_matrix[rownames(rpkm_matrix) %in% gene,]+1)
		data <- data.frame(
			pseudotime=lineage,
			gene=t(sub_data),
			condition=condition
			)
		colnames(data) <- c("pseudotime", "gene", "condition")
		data <- na.omit(data)
		p <- ggplot(data, aes(x=pseudotime, y=gene))+
		geom_point(shape = 21, size = 2.5, stroke=0.5, aes(fill=condition))+
		geom_smooth(color="black")+
		# xlim(0, max_pseudotime)+
		ylim(0, max_exp)+
		theme_bw()
		myplots[[i]] <<- p
	})
	plot_grid(plotlist =myplots, nrow=ncol(pseudotime))
}

from slingshot.

kstreet13 avatar kstreet13 commented on July 21, 2024

Hi!

Sorry for changing so many things the other day (I'm making a big push to get the package ready for submission to Bioconductor), but I really appreciate all the feedback!

There is an accessor function for pulling out the matrix of pseudotimes (called pseudotime) as well as the matrix of weights (curveWeights). So for setting a weight threshold, I think this might be a little easier:

pst <- pseudotime(slingshot_output)
pst[curveWeights(slingshot_output) <= wthresh] <- NA

And thanks for individual gene plotting suggestion! Now that the big overhaul is done, that's the next thing I hope to add.

from slingshot.

Related Issues (20)

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.