Commit a5109444 authored by ziegenhain@bio.lmu.de's avatar ziegenhain@bio.lmu.de
Browse files

Prevent crashes in barcode selection, set up for stats generation

parent 881eff21
Loading
Loading
Loading
Loading
+36 −21
Original line number Diff line number Diff line
@@ -47,8 +47,13 @@ setDownSamplingOption<-function( down ,bccount, filename=NULL){
  cut <- .FindBCcut(bccount)
  nkeep<-bccount[n>=cut][,list(s=.N)]
  if(nkeep<10){
    print("Attention! Adaptive BC selection gave < 10 cells so I will now use top 100 cells!")
    print("Warning! Adaptive BC selection gave < 10 cells so I will try to use top 100 cells!")
    if(nrow(bccount)<100){
      print("Less than 100 barcodes present, will continue with all barcodes...")
      bccount[1:nrow(bccount),keep:=TRUE]
    }else{
      bccount[1:100,keep:=TRUE]
    }
  }else{
    bccount[n>=cut,keep:=TRUE]
    print(paste(nkeep," barcodes detected.",sep=""))
@@ -80,7 +85,18 @@ setDownSamplingOption<-function( down ,bccount, filename=NULL){
  return( bccount[keep==TRUE,XC] )
}
.cellBarcode_number  <- function( bccount, bcNumber){
  if(bcNumber <= nrow(bccount)){
    bccount[1:bcNumber,keep:=TRUE]
  }else{
    print("Warning! The data contains fewer barcodes than requested so I will try to use top 100 cells!")
    if(nrow(bccount)<100){
      print("Less than 100 barcodes present, will continue with all barcodes...")
      bccount[1:nrow(bccount),keep:=TRUE]
    }else{
      bccount[1:100,keep:=TRUE]
    }
  }

  return(bccount[keep==TRUE,XC])
}
.cellBarcode_known   <- function( bccount, bcfile  ){
@@ -137,4 +153,3 @@ plotReadCountSelection<-function(bccount , mads, filename){
  abline(h=MAD_up,col="red")
  dev.off()
}
+1 −0
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ if
[[ "$whichStage" == "Counting" ]] ||
[[ "$whichStage" == "Summarising" ]]
then
  yamlnew=$outdir/$project.postmap.yaml  #note! mapping creates a temporary new yaml because of custom GTF!
  if [[ "$isstats" == "yes" ]]; then
    echo "Starting descriptive statistics..."
    if [[ "$isslurm" == "yes" ]]; then
+3 −2
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@ library(methods)
library(data.table)
library(yaml)
library(ggplot2)

library(Matrix)
library(dplyr)
##########################
myYaml<-commandArgs(trailingOnly = T)
opt   <-read_yaml(myYaml)