Description Usage Arguments Value Examples
View source: R/createPSN_MultiData.R
Wrapper to create custom input features (patient similarity networks)
1 2 3 4 5 6 7 8 9 10 |
dataList |
(list) key is datatype (e.g. clinical, rna, etc.,), value is table or RangedData) Note that unit names should be rownames of the data structure. e.g If dataList$rna contains genes, rownames(dataList) = gene names |
groupList |
(list) key is datatype; value is a list of unit groupings for that datatype. e.g. If rna data will be grouped by pathways, then groupList$rna would have pathway names as keys, and member genes as units. Each entry will be converted into a PSN. |
pheno |
(data.frame) mapping of user-provided patient identifiers (ID) with internally-generated identifiers. |
netDir |
(char) path to directory where networks will be stored |
filterSet |
(char) vector of networks to include |
verbose |
(logical) print messages |
customFunc |
(function) custom user-function to create PSN. Must take dataList,groupList,netDir as parameters. Must check if a given groupList is empty (no networks to create) before the makePSN call for it. This is to avoid trying to make nets for datatypes that did not pass feature selection |
... |
other parameters to makePSN_NamedMatrix() or makePSN_RangedSets() |
(char) vector of network names. Side effect of creating the nets
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | library(curatedTCGAData)
library(MultiAssayExperiment)
curatedTCGAData(diseaseCode='BRCA', assays='*',dry.run=TRUE)
# fetch mrna, mutation data
brca <- curatedTCGAData('BRCA',c('mRNAArray'),FALSE)
# get subtype info
pID <- colData(brca)$patientID
pam50 <- colData(brca)$PAM50.mRNA
staget <- colData(brca)$pathology_T_stage
st2 <- rep(NA,length(staget))
st2[which(staget %in% c('t1','t1a','t1b','t1c'))] <- 1
st2[which(staget %in% c('t2','t2a','t2b'))] <- 2
st2[which(staget %in% c('t3','t3a'))] <- 3
st2[which(staget %in% c('t4','t4b','t4d'))] <- 4
pam50[which(!pam50 %in% 'Luminal A')] <- 'notLumA'
pam50[which(pam50 %in% 'Luminal A')] <- 'LumA'
colData(brca)$ID <- pID
colData(brca)$STAGE <- st2
colData(brca)$STATUS <- pam50
# keep only tumour samples
idx <- union(which(pam50 == 'Normal-like'), which(is.na(st2)))
cat(sprintf('excluding %i samples\n', length(idx)))
tokeep <- setdiff(pID, pID[idx])
brca <- brca[,tokeep,]
pathList <- readPathways(fetchPathwayDefinitions("October",2020))
brca <- brca[,,1] # keep only clinical and mRNA data
# remove duplicate arrays
smp <- sampleMap(brca)
samps <- smp[which(smp$assay=='BRCA_mRNAArray-20160128'),]
notdup <- samps[which(!duplicated(samps$primary)),'colname']
brca[[1]] <- brca[[1]][,notdup]
groupList <- list()
groupList[['BRCA_mRNAArray-20160128']] <- pathList[seq_len(3)]
makeNets <- function(dataList, groupList, netDir,...) {
netList <- c()
# make RNA nets: group by pathway
if (!is.null(groupList[['BRCA_mRNAArray-20160128']])) {
netList <- makePSN_NamedMatrix(dataList[['BRCA_mRNAArray-20160128']],
rownames(dataList[['BRCA_mRNAArray-20160128']]),
groupList[['BRCA_mRNAArray-20160128']],
netDir,verbose=FALSE,
writeProfiles=TRUE,...)
netList <- unlist(netList)
cat(sprintf('Made %i RNA pathway nets\n', length(netList)))
}
cat(sprintf('Total of %i nets\n', length(netList)))
return(netList)
}
exprs <- experiments(brca)
datList2 <- list()
for (k in seq_len(length(exprs))) {
tmp <- exprs[[k]]
df <- sampleMap(brca)[which(sampleMap(brca)$assay==names(exprs)[k]),]
colnames(tmp) <- df$primary[match(df$colname,colnames(tmp))]
tmp <- as.matrix(assays(tmp)[[1]]) # convert to matrix
datList2[[names(exprs)[k]]]<- tmp
}
pheno <- colData(brca)[,c('ID','STATUS')]
netDir <- tempdir()
pheno_id <- setupFeatureDB(colData(brca),netDir)
createPSN_MultiData(dataList=datList2,groupList=groupList,
pheno=pheno_id,
netDir=netDir,customFunc=makeNets,numCores=1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.