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

prevent crashing when wrong barcodefile is given

parent 15f6112f
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -101,7 +101,19 @@ setDownSamplingOption<-function( down ,bccount, filename=NULL){
}
.cellBarcode_known   <- function( bccount, bcfile  ){
  bc<-read.table(bcfile,header = F,stringsAsFactors = F)$V1
  if( any( bc %in% bccount$XC ) ){
    bccount[XC %in% bc,keep:=TRUE]
  }else{
    print("Warning! None of the annotated barcodes were detected.")
    if(nrow(bccount)<100){
      print("Less than 100 barcodes present, will continue with all barcodes...")
      bccount[1:nrow(bccount),keep:=TRUE]
    }else{
      print("Continuing with top 100 barcodes instead...")
      bccount[1:100,keep:=TRUE]
    }
  }
  
  return(bccount[keep==TRUE,XC])
}