MarioniLab / scran

Clone of the Bioconductor repository for the scran package.
https://bioconductor.org/packages/devel/bioc/html/scran.html
39 stars 23 forks source link

Error with cyclone #117

Open SarahE97 opened 4 months ago

SarahE97 commented 4 months ago

Hello,

We use cyclone in our sce pipeline and I'm having issues with some files and not others. It seems somewhat random when it does happen, and it is now happening with files I've successfully run before. This occurs after running a number of other steps, and the error in question is this: Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic (bolded in the text).

It's easy to progress through other aspects of the pipeline (normalizing using lognormcounts), but then the more substantial error occurs when trying to transfer to Seurat using the as.Seurat function. (Warning: i must be one of "BetshotzTest1_AAACCCAAGGGACCAT-1", "BetshotzTest1_AAACCCAGTTCGTAAC-1",) If I run the same files without cyclone, this error does not occur. Have you seen anything like this before? I can't figure out why this is happening even to some files (but not all) I've done before. Thanks so much, Sarah

I use Seurat version 5 (I have retried with Seurat 4 with the same issue) and version 1.28.2 of scran. Let me know what other information you need.

#############Cyclone############## cycloneSpeciesMarkers <- "mouse_cycle_markers.rds" # "human_cycle_markers.rds"

egDB <- "org.Mm.eg.db" # "org.Hs.eg.db" if human

unload dplyr to run next line

anno <- select(get(egDB), keys=rownames(sce), keytype="SYMBOL", column="ENSEMBL") 'select()' returned 1:many mapping between keys and columns cycScores <- cyclone(sce,gene.names=anno$ENSEMBL[match(rownames(sce),anno$SYMBOL)],

  • pairs=readRDS(system.file("exdata",cycloneSpeciesMarkers,package="scran"))) cycScores$phases <- as.factor(cycScores$phases) cycScores$confidence <- sapply(seq_along(cycScores$phases),function(i)
  • cycScores$normalized.scores[i,as.character(cycScores$phases[i])]) for (l in names(cycScores)) {
  • if (is.null(dim(cycScores[[l]]))) {
  • names(cycScores[[l]]) <- colnames(sce)
  • } else {
  • rownames(cycScores[[l]]) <- colnames(sce)
  • }
  • } colData(sce)$CyclonePhase <- cycScores$phases colData(sce)$CycloneConfidence <- cycScores$confidence layout(matrix(c(1,2,1,3,1,4),2),widths=c(2,5,1),heights=c(1,9)) par(mar=rep(0,4),mgp=2:0) plot.new() title("Cell cycle phase assignment confidence, library sizes, and distribution per sample",line=-2,cex.main=1.5) par(mar=c(3,3,1,1),bty="n") boxplot(tapply(cycScores$confidence,cycScores$phases,c),
  • col=qualitative_hcl(3,alpha=.7,palette="Dark 3"),
  • ylab="Normalized score of assigned cell cycle phase") Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic par(mar=c(3,3,1,1)) cycDlibSize <- tapply(log10(colData(sce)$sum),cycScores$phases,function(X) density(X)) plot(x=NULL,y=NULL,ylab="Density",xlab=expression(Log[10]~"Library Size"),
  • xlim=range(log10(colData(sce)$sum)),
  • ylim=c(min(sapply(cycDlibSize,function(X) min(X$y))),
  • max(sapply(cycDlibSize,function(X) max(X$y))))) for (x in 1:length(cycDlibSize)) {
  • lines(cycDlibSize[[x]],lwd=3,
  • col=qualitative_hcl(3,alpha=.7,palette="Dark 3")[x])
  • } legend("topleft",bty="n",horiz=T,lwd=rep(3,3),legend=levels(cycScores$phases),
  • col=qualitative_hcl(3,alpha=.7,palette="Dark 3")) par(mar=c(3,3,1,1)) barplot(cbind(table(cycScores$phases)),
  • col=qualitative_hcl(3,alpha=.7,palette="Dark 3"),
  • ylab="Number of cells")

################To As.Seurat###################

seur <- as.Seurat(sce)

Warning: Feature names cannot have underscores (''), replacing with dashes ('-') Warning: Feature names cannot have underscores (''), replacing with dashes ('-') Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-') Warning: i must be one of "BetshotzTest1_AAACCCAAGGGACCAT-1", "BetshotzTest1_AAACCCAGTTCGTAAC-1", "BetshotzTest1_AAACCCATCGGTTGTA-1", "BetshotzTest1_AAACGAAAGTCCCTAA-1", "BetshotzTest1_AAACGAACAGTATTCG-1", "BetshotzTest1_AAACGAATCCTAGCCT-1", "BetshotzTest1_AAACGAATCGCCGTGA-1", "BetshotzTest1_AAACGCTCAACGGTAG-1", "BetshotzTest1_AAAGAACGTGGGTATG-1", "BetshotzTest1_AAAGGATAGCATATGA-1", "BetshotzTest1_AAAGGATGTGACAACG-1", "BetshotzTest1_AAAGGATTCGACACCG-1", "BetshotzTest1_AAAGGATTCTGTGTGA-1", "BetshotzTest1_AAAGGGCAGAGTTGTA-1", "BetshotzTest1_AAAGGGCAGTTCGCAT-1", "BetshotzTest1_AAAGGGCGTAATCAAG-1", "BetshotzTest1_AAAGGTACATGGCGCT-1", "BetshotzTest1_AAAGGTAGTGCGACAA-1", "BetshotzTest1_AAAGGTAGTGTCTTGA-1", "BetshotzTest1_AAAGTCCGTCAGGCAA-1", "BetshotzTest1_AAAGTCCTCGGTAACT-1", "BetshotzTest1_AAAGTGAGTATCGATC-1", "BetshotzTest1_AAAGTGAGTGGATACG-1", "BetshotzTest1_AAAGTGAGTTAACAGA-1", "BetshotzTest1_AAATGGAAGACGGTCA-1", "BetshotzTest1_AAATGGAGTCATCAGT-1", "BetshotzTest1_AAATGGAGTTCGTTCC-1", "Betshotz [... truncated]

LTLA commented 4 months ago

I can't really read your code, suggest using triple backtick code blocks instead.

I will only say that

If I had to guess, some annotation has updated in org.Hs.eg.db that is causing your results to change.