Skip to content

Instantly share code, notes, and snippets.

@AmyOlex
Created May 8, 2018 16:53
Show Gist options
  • Save AmyOlex/af8db47c91c3a0ec1bae3adc0704b4ae to your computer and use it in GitHub Desktop.
Save AmyOlex/af8db47c91c3a0ec1bae3adc0704b4ae to your computer and use it in GitHub Desktop.

Revisions

  1. AmyOlex created this gist May 8, 2018.
    11 changes: 11 additions & 0 deletions UpperQuantilNorm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    ## From forum post https://bioinformatics.stackexchange.com/questions/2586/how-to-apply-upperquartile-normalization-on-rsem-expected-counts

    ## this uses all data in the quantile function, including those that are not expressed
    ## Assumes genes are rows and samples are columns
    data.quantileAll <- apply(unnormalized_mtx, 2, function(x){quantile(x, 0.75)})

    ## this uses onlt the values that are greater than zero.
    ##data.quantileExpressed <- apply(unnormalized_mtx, 2, function(x){quantile(x[x>0], 0.75)});

    data.norm <- t(t(unnormalized_mtx) / data.quantileAll)
    write.table(data.norm, file="UpperQuantileNorm_Log2TPM_CancerFocusGenes_TCGA817_and_Harrell_NOTHumanPercentCorrected_10MillionHumanReadFiltered.txt",sep="\t", quote=FALSE)